WordPress – How to hide a Category from Front page, Archives, Feeds, Searches and Category Widget A great plugin to exclude a category from your WordPress Web Site... and a neat PHP script to deal with the Category Widget as well

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   QueryString parameter within the destination page URL.

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

That’s it for now… Happy coding!

 

RELATED POSTS

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies. Microsoft MVP for Development Technologies since 2018.

View all posts by Ryan