How to Exclude a Category from the Home Page

Total
0
Shares

This is the most common customization requests for WordPress, “How do I prevent posts from a particular category from displaying on my home page?” As I have a category about WordPress Product lists “Collections” and I want to omit it from the post loop so that posts from this category will not display on my Home Page. But this post will still appear in your content field. To eliminate from feed and from Hope page there is excellent WordPress plugin Stealth Publish.

excluded

The simplest way for including and excluding a Category post from Home page is to modify the query_posts function as follow:

Excluding a category from the home page

<?php if ( is_home() ) {

query_posts( '&cat=-4' );

}

// your usual Loop can go here

?>
Where 4= The required Category ID and that Id you can find in category section. Go to Category click on Edit and in URL you can find Category ID as shown in the picture below.
Category-ID

In query_posts( ‘&cat=-4‘ ), a dash (or minus sign, ““) appearing before a parameter value signifies exclusion. Thus, here I wanted to exclude a category number four, When this code is placed before my loop, posts in Collections category will not be displayed.

Showing Only One Category on the Home Page

The above solution was for my own problem, Perhaps instead of excluding a category, you want to show only one category. Than there is minor change in the query_posts, All you have to replace the dash (or minus sign, “-“) as follows:

Showing only one category

<?php if ( is_home() ) {

query_posts( '&cat=7' );

}

// your usual Loop can go here

?>

Be careful, and proofread your Loops!
If you are not familiar with coding than the best option is to use WordPress Plugins for that purpose.

WordPress Plugins for Excluding Category

1. Stealth Publish

Prevent specified posts from being featured on the front page or in feeds. Beneficial in instances where you want to publish new content without any fanfare and just want the post added to the archive and category pages and its permalink page.

2. Simply Exclude

Provides an interface to selectively exclude/include categories, tags, authors and pages from the 4 actions used by WordPress. Simply Exclude is a WordPress plugin that 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 it does all the work for you!

3. Advanced Category Excluder

This plugin was born because there was a no other real alternative to enable content separation and some CMS like functionalities in WordPress. The main goal was, to enhance WordPress’s features, to hide some unwanted categories, from defined parts of the blog.

4. Ultimate Category Excluder

This is a WordPress plugin that 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!

Leave a Reply

Your email address will not be published. Required fields are marked *

Sign Up for Our Newsletters

Get notified of the best deals on our WordPress themes.

You May Also Like