Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #704162

    Rad
    Moderator

    Hi Richard,

    Ah, you’re trying to exclude them from the widget, and not from the blog posts. And please don’t mix up jQuery coding and PHP Coding. jQuery goes to customizer’s custom javascript, while PHP goes directly to child theme templates and functions.php

    Please change your code to this,

    add_filter( 'widget_categories_args', 'wpsites_exclude_widget_category', 99 );
    add_filter( 'widget_categories_dropdown_args', 'wpsites_exclude_widget_category', 99 );
    function wpsites_exclude_widget_category( $cat_args ) {
    $cat_args['exclude'] = '11';
    return $cat_args;
    }
    

    Thanks, and please clear your cache before testing.

    #704697

    Ritchieb
    Participant

    Hi support team,

    thanks for your help but i have to say that i don’t notice any difference with the code in post #703825
    The archive stills shows a lot of months in which only reviews where placed.

    see image which shows you as an example the archive of december and on the right hand side i have a screenshot of the post which is a review.

    Thanks again

    #705051

    Rad
    Moderator

    Hi Richard,

    Sorry for the confusion, the code provided will only exclude the category from widgets, and for categories only (not dates).

    It’s not effective for widget archives, they are not categories, they are just date. And the code as no effect for month archive pages either, because it’s not category nor a widget.

    I’m not really sure what you’re trying to do, maybe it’s best to provide a video recording 🙂

    Though, this is not part of X, it’s rather wordpress customization. I can’t promise a fix or solution, but I’ll try to understand it first 🙂

    Thanks!

    #705702

    Ritchieb
    Participant
    This reply has been marked as private.
    #705742

    Paul R
    Moderator

    Hi,

    Thanks for the video.

    I now fully understand what you are trying to achieve, regretfully this isn’t a feature offered by X. It could be possible with custom development, but this would be outside the scope of support we can offer. You may wish to consult a developer to assist you with this. X is quite extensible with child themes, so there are plenty of possibilities. Thanks for understanding. Take care!

    #705822

    Ritchieb
    Participant

    Found the solution and i want to share this with you and other users of X. Because i can imagine that others want a solution for excluding a certain categorie from the archive month list (archive widget)

    Just copy the next code into your child’s php page and put your category ID in the place where now category number 7 is.
    Multiple page can be given in with a comma in between them.

    /* exclude categories from category widget */
    add_filter(“widget_categories_args”,”exclude_widget_categories”);
    function exclude_widget_categories( $args ){
    $args[“exclude”] = ‘7’; //multiple = ‘7,8,9’ using IDs from Posts=>Categories page in admin
    return $args;
    }

    /* exclude categories from archive list widget */
    add_filter(‘getarchives_join’,’customarchives_join’);
    add_filter(‘getarchives_where’,’customarchives_where’);
    function customarchives_join($x) {
    global $wpdb;
    return $x.” INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)”;
    }
    function customarchives_where($x) {
    global $wpdb;
    $exclude=’7′; //multiple = ‘7,8,9’ using IDs from Posts=>Categories page in admin
    return $x.” AND $wpdb->term_taxonomy.taxonomy = ‘category’ AND $wpdb->term_taxonomy.term_id NOT IN ($exclude)”;
    }

    #705870

    Paul R
    Moderator

    Thanks for sharing.

    Have a great day!