3 ways to exclude categories from WordPress home page, archives, and feeds

Sometimes you will need to hide one or some categories from WordPress home page, or archives page, or in feeds. So today we will show you how to do this.

1. Use Plugin Ultimate Category Excluder

image

Ultimate Category Excluder allows you to quickly and easily exclude categories from your front page, archives, and feeds. Just select which categories you want to be excluded, and UCE does all the work for you!

Ultimate Category Excluder Download

2. Use plugin Simply Exclude

image

Simply Excludeprovides an interface to selectively exclude/include all Taxonomies, Post Types and Users from the 4 actions used by WordPress. is_front, is_archive, is_search and is_feed:

  • is_front – When the user views the Front page.
  • is_archive – When the user views an category or tags Archive.
  • is_search – When the user views a search result page.
  • is_feed – When a Feed is viewed/requested.

Simply Exclude Screenshot

Simply Exclude Download

3. add code to function.php

function custom_exclude_category( $query ) {

if ( $query->is_home() && $query->is_main_query() ) {

$query->set( ‘cat’, ‘-1,-3’ ); //-1,-3 are the categories which you want to exclude

}

}

add_action( ‘pre_get_posts’, ‘custom_exclude_category’ );

× -