How to Exclude a Category from the Home Page

Nur . Posted in How-To, Plugins, Themes 2451 Views

This is the  most common customization requests for WordPress, “How do I prevent
posts from a certain category from displaying on my home page?!”   As I have a categry about WordPress Powered Website “Showcase” and I want to omit from the post loop so that post related to this category will no display on my Home Page. But this post still will be appear in your content field. To eliminate from feed and from Hope page there is excellent WordPress plugin Stealth Publish.

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.

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 Showcase 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 archive and category pages and its own permalink page.

Download | Read More

2. Simply Exclude

Provides an interface to selectively exclude/include categories, tags, authors and pages from the 4 actions used by WordPress.

Download | Plugin Homepage

3. Advanced Category Excluder

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

Download | Plugin Homepage

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!

Download | Ultimate Category Excluder

Other useful resources and Reference:

4 Ways To Exclude WordPress Category From RSS Feeds

Exclude Categories from Feed, Archives, Search, and Home page in WordPress

Category Hacks for WordPress Theme Designers

http://failedandforgotten.deviantart.com/art/excluded-95768731

Nur

I am a Wordpress, Website Developer and Designer, creator @ WP Arena, Provide Free WordPress consultation and can help to install WordPress in a secure way to small businesses and bloggers.

Free & Professional WordPress Security Service Free & Professional WordPress Security Service

We Love WordPress. WordPress Arena is a place for WordPress Developers and Designers, providing Tips, tricks, tools and resources to build a website or blog on WordPress. We also present The WordPress Showcase for all kind of WordPress Powered Websites.


Copyright © 2014 WP Arena All Rights Reserved

Divi WordPress Theme