How to Exclude a Category from WordPress Homepage?

How to Exclude Category from WordPress Homepage

Do you want to Exclude a Category from WordPress Homepage?

Category refers to the predefined taxonomies used to sort contents and blogs into different sections. It makes visitors easy to find the content they are looking for.

By default, WordPress displays posts from all categories on your website’s homepage. If you have a category with unnecessary posts, it can somehow degrade the quality of your homepage. In this case, excluding a category is the best option. 

In this tutorial, we will learn to exclude a category from the WordPress homepage. There are two different methods i.e using plugin and code. We will briefly learn to exclude using both methods.

Exclude Category using Plugin

In order to do it through a plugin, you will firstly need to install the plugin Ultimate Category Excluder

Likewise in order to install the plugin in a proper way following our tutorial ‘How to install a new WordPress plugin?’

After you install the plugin, 

  • Next, Click on Settings>>Category Excluder
  • Select the categories you would like to remove from the Homepage from the Exclude from FrontPage.
  • Update the changes. 

Similarly, the category you selected will be excluded from the homepage. This is the steps to follow using the plugin. 

Exclude Category using Code

Additionally, in order to do it through code, you need to add some additional code in your WordPress file. 

Simply, add the below-mentioned code in your funtion.php file or a site-specific plugin.

function exclude_category_home( $query ) {

if ( $query->is_home ) {

$query->set( ‘cat’, ‘-5’ );


return $query;


add_filter( ‘pre_get_posts’, ‘exclude_category_home’ );

Similarly the category gets excluded from your website. 

Moreover these are the two ways to exclude a category from your WordPress homepage. I hope you are now able to make changes on your WordPress website as you want. 


Please enter your comment!
Please enter your name here