How to Exclude Specific Category Posts From Your WordPress Home Page
If you want to exclude specific category/categories posts from your WordPress home page, then this article is for you.
By default WordPress doesn’t allow the user’s to exclude a category posts from displaying on home page.
So here i will teach you the two methods to exclude a specific category posts from your WordPress home page.
let’s Start.
1: Exclude Category from Home Page Using Plugin
You can exclude specific category posts from home page by downloading Ultimate Category Excluder plugin.
After download, install & activate the plugin. Then go to Settings → Category Excluder
This plugin will display all the categories of your site.
Now check the categories under ‘Exclude from Front Page’ which you want to exclude from home page.
This plugin also allows you to exclude specific categories from feeds, archives and search result.
After categories checked, click on the Update button.
Now the checked categories posts will not shows on your site home page.
2: Exclude Category from Home Page Using Code
In this method you have to add a piece of code to your theme, and you will be able to exclude specific category posts from your home page.
Add the below code to your theme functions.php or site-specific plugin.
function exclude_category_home( $query ) {
if ( $query->is_home ) {
$query->set( 'cat', '-26' );
}
return $query;
}
add_filter( 'pre_get_posts', 'exclude_category_home' );
Its important to replace the ID (-26) with your category ID and don’t forget the (-) sign with ID.
If you don’t know how to find category ID, read it it will guide you to find category ID.
You can also exclude multiple categories from your home page, for this you have to add comma separate category ID’s in the above code.
For example : (-55,-6,-12)
{it will exclude categories from your home page, which has 55, 6 and 12 ID}
Here are a few tutorials for you to read next:
- How to Find Post, Page, Category, or User ID in WordPress
- How To Add Social Media Icons To WordPress Menu
- How to Backup Your WordPress Site Automatically [With Pictures]
- How To Change The Footer Copyright Text Of Customizr WordPress Theme
- How to create Table in WordPress [With Pictures]
- How to Add Website to Google [With Pictures]
If you find this tutorial helpful, then please Subscribe to our YouTube Channel for video tutorials, and share this article on social media.