I have the ‘Categories: Archive by Categories’ widget in my sidebar. Clicking ‘Select Category’ displays a scroll-able dropdown list of all categories.
There is one category however that I want to exclude from the dropdown list so that users/readers cannot select or see any posts in that category.
How can I do that?
Hi zimbo!
Can you please show us a link that the widget is in place, so we can try debug the issue?
We would really appreciate.
Thanks a lot
Best regards,
Basilis
Page here.
I want to stop DoNotShow and NewsTicker categories from appearing in the ‘Categories: Archive by Categories’ widget dropdown list in the sidebar.
Hey!
Please add following code to Functions.php file in Appearance > Editor
add_filter( 'widget_categories_args', 'avia_exclude_widget_category', 10, 1 );
add_filter( 'widget_categories_dropdown_args', 'avia_exclude_widget_category', 10, 1 );
function avia_exclude_widget_category( $cat_args ) {
$cat_args['exclude'] = array('11','38');
return $cat_args;
}
and replace 11 and 38 with your category IDs
Cheers!
Yigit
Thanks Yigit but there is an error in that code – line 3 should be
function avia_exclude_widget_category( $cat_args ) {
and not wpsites_… but I changed it, and it now works. :-)