Archived topic
Hide specific categories from WordPress category widget
13 replies · Started by Royal Rangers on January 10, 2023
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.
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");
Still don´t working.
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.
Any cache plugin.
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.
I trying both code on another page, still don´t working.
I try another webpage and still doesn´t work.
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/
I adding code in functions.php via child-theme.
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
Hi, yes I can.
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.
Doesn´t work too. I will try a WordPress support. Thanks for help.
No problem :)