Hide 'Featured' Category from Category List

Posted in: Newspaper
Post count: 9544

Hi,
this one may be obvious to somebody, but couldn’t figure it out without hacking something, so thought I’d query the gang.

Okay:
we use the “Featured” category in order to have that show as poster/large image on each category page automatically and obviously on some sites for the slider stuff on home page.

However, this also adds “Featured” as a clickable category in the sidebar lineup of categories, which shouldn’t really be there for our purposes.

I can remove it from the sitemap using function in YOAST SEO, but a simple list of say five site categories on sidebar, starts with Featured in one case, which we don’t want.

Presumably I could just make a text based widget and put the categories there, but that would lose the functionality and any of the schema stuff which might be inserted by theme/WP at some point.

Seems like there should be a function to simply hide one category from the sidebar query, but wasn’t able to figure out with a short attention span today.

Any pointers on this would be great, thanks 🙂

  • This topic was modified 11 years by simchris.
Post count: 6600

Hi Christopher,

You can try to use this filter in functions.php :

function set_category_widget_parameters($args) {
    $args['exclude'] = '98';
    return $args;
}
add_filter('widget_categories_args','set_category_widget_parameters');

Just replace “98” with your featured category ID.
Hope this helps you!

Thanks

Post count: 9544

Awesome. I haven’t built my own themes since 2011 and getting very rusty on some of the queries. Thanks for that! 🙂

Post count: 6600

Glad I could help!
Have a nice day!

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