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.
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.
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}
If you find this tutorial helpful, then please Subscribe to our YouTube Channel for video tutorials, and share this article on social media.
In this article, I will share a trick to remove advertisement banners and the sidebar…
Color plays an essential role in design and everyday life. It can draw your attention…
Have you ever been creeped out by an ad appearing in your social media feed…
Imagine you have just finished working on your favorite image-editing program and your masterpiece is…
If you want to highlight the current active page link anywhere in your WordPress website…
Hey, guys! All of you who were using any clipboard on their mobile phones must…