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.
The simplest way for including and excluding a Category post from Home page is to modify the query_posts function as follow:
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.
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.

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.













Responses (0 )