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 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!

 

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

2 Comments on “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

  1. This is the only solution I can find online, but it breaks my site. I added to the bottom of my child theme’s function file. Do you know of any other solution?

    Thanks!

  2. Thanks heaps!!!

    I initially tried adding your code through the “Code Snippets” plugin, but it didn’t work.

    I later got it to work with another code snippets plugin called “My Custom Functions” by Space X-Chimp.
    :D

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.