Site icon Ryadel

WordPress - How to hide a Category from Front page, Archives, Feeds, Searches and Category Widget

Wordpress - How to hide a Category from Front page, Archives, Feeds, Searches and Category Widget

When dealing with a WordPress Web Site you might want to hide or exclude one or more Categories without actually deleting them: in other words, to prevent them from being shown within your Front Page Menu, Archive Pages, Feeds, search results and so on.

The best way to achieve such result is installing Ultimate Category Excluder, also known as UCE: a great Wordpress plugin that allows you to quickly and easily exclude categories from your front page, archives, feeds, and searches with a user-friendly interface. To get a glimpse of how it works, look at the screenshot below:

Wordpress - How to hide a Category from Front page, Archives, Feeds, Searches and Category Widget

Unfortunately, the Ultimate Category Excluder plugin is currently unable to exclude the Categories from the WordPress built-in Category Widget, which is often the way Categories are shown within the Website's Home Page. If you want to hide a Category from everywhere, this is definitely a problem you might want to fix.

Luckily enough, it's possible to overcome such limitation with the following PHP script:

Add this to your WordPress theme's function.php file, enumerating the comma-separated IDs related to the Categories you want to hide, and you'll get rid of them without issues. To find the Category ID, just go to the Posts > Categories section of the WordPress Admin Panel, edit them and look at the tag_ID  QueryString parameter within the destination page URL.

For additional info regarding this neat technique and/or the widget_categories_args  filter, you can read the official WordPress Codex.

That's it for now... Happy coding!

 

Exit mobile version