For any reason if you want to hide specific category in WordPress homepage or from other pages like archives, feeds etc, we have put together some solution to get it done for you.
Now, the reason can be different for different users to achieve this. In fact, I am looking forward to change the navigation structure of this blog by creating certain categories and hiding some.
So, how do we achieve that?
There are number of discussion regarding how to hide specific category in WordPress on forums like stackexchange or the WordPress forum. So, let’s find the easier way to achieve our goal
[symple_box style=”boxinfo”]Hide a Category in WordPress[/symple_box]
First let’s look at the available WordPress plugins which will help us to hide specific category in WordPress.
WP Hide Category
WP Hide Category is one of those prominent WordPress plugins which will help us to hide certain categories as per requirement. It’s a very simple WordPress plugin to hide specific category in your blog’s page
Restrict Categories
Another really useful WordPress plugin which all help us to achieve our target, this plugin allows admin to select which categories users can view, add, and edit in the Posts edit screen.
Another benefit of this plugin is, you can restrict categories based or user type.
Ultimate Category Excluder
Ultimate Category Excluder is a WordPress plugin that allows you to quickly and easily exclude categories from your front page, archives, feeds, and searches. Just select which categories you want to be excluded, and UCE does all the work for you.
WordPress generally displays the latest posts on the homepage. Now, if you want to exclude certain categories from displaying on homepage, you can do that by adding some code to your theme file.
The easiest way to do that is by adding the following code to your functions.php file. Don’t forget to replace the category IDs with the ones you want to exclude
function exclude_category_home( $query ) {
if ( $query->is_home ) {
$query->set( 'cat', 'IDs' );
}
return $query;
}
add_filter( 'pre_get_posts', 'exclude_category_home' );
Finding the category ID is really easy, however newbie WordPress users may not be aware of the process to find the category ID. Follow the steps below to find the category ID.
Go to Posts > Categories and hover over the category you want to find the ID for, on hover you will see the ID below on your screen. Alternately you can click on edit for that particular category to find the ID.
In the case below we are trying to find the ID for plugin category of Indexwp
So, now you can decide if you want to add the code or use a plugin to hide specific category in WordPress site, both the option will fulfill your requirement. Don’t forget to backup your site before you add the new code to your functions.php file
Leave a Reply