Site logo

[Resolved] Hide specific categories from WordPress category widget

Home Forums Support [Resolved] Hide specific categories from WordPress category widget

Home Forums Support Hide specific categories from WordPress category widget

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #2489870
    Royal Rangers

    Hi, how I can hide a specific category from dropdown category widget. I try this code:

    function exclude_widget_categories($args){
        $exclude = "23";
        $args["exclude"] = $exclude;
        return $args;
    }
    add_filter("widget_categories_args","exclude_widget_categories");

    Doesn´t work. Is there any other way to make a dropdown custom menu?

    Thanks for help.

    #2490048
    David
    Staff
    Customer Support

    Hi there,

    try the widget_categories_dropdown_args filter instead:

    
    function exclude_widget_categories($args){
        $exclude = "23";
        $args["exclude"] = $exclude;
        return $args;
    }
    add_filter("widget_categories_dropdown_args","exclude_widget_categories");
    #2493421
    Royal Rangers

    Still don´t working.

    #2493422
    Leo
    Staff
    Customer Support

    The code looks good to me – make sure the category ID is set correctly.

    Any caching plugins that might need to be cleared?

    If not can you check with WordPress’ support team to see if we’ve missed anything?

    Or I Googled “widget_categories_dropdown_args” and saw quite a few examples that might worth trying as well.

    #2493429
    Royal Rangers

    Any cache plugin.

    #2493432
    Leo
    Staff
    Customer Support

    Any cache plugin.

    I don’t see any from looking at the source but that would be up to you to confirm. Sometimes there are server and hosting caching as well.

    I found another post that suggested the same code so I’d assume that the code is correct:
    https://basicwp.com/exclude-categories-from-category-widgets-in-wordpress/

    You would need to check with WP’s support team if it doesn’t work as this isn’t something the theme can control.

    Thanks for your understanding.

    #2493444
    Royal Rangers

    I trying both code on another page, still don´t working.
    I try another webpage and still doesn´t work.

    #2493613
    Ying
    Staff
    Customer Support

    How did you add the code?

    Make sure it’s added using one of the methods introduced here:
    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #2493720
    Royal Rangers

    I adding code in functions.php via child-theme.

    #2493726
    Fernando
    Customer Support

    Hi Jan,

    Can you provide admin login credentials so we can take a closer look?

    Please use the Private Information field for this: https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information

    #2498106
    Royal Rangers

    Hi, yes I can.

    #2498177
    Leo
    Staff
    Customer Support

    The code is added in the correct place from what I can tell.

    Would setting the snippet to Run Everywhere instead of Site Wide Header help?

    If not then please check with WordPress support team to see if they have an idea why it’s not working.

    Thanks for your understanding.

    #2498370
    Royal Rangers

    Doesn´t work too. I will try a WordPress support. Thanks for help.

    #2499251
    Leo
    Staff
    Customer Support

    No problem 🙂

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.