hiding post

Hide Specific Category Posts at Home page

To hide specific category posts at home page simply place this below single line code before the main loop start at home page.

<?php if ( is_home() ) {query_posts( 'cat=-1' ); } ?>

Complete loop with this above code will look like:

<?php if ( is_home() ) {query_posts( 'cat=-1' ); } ?>
  <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>
     <!-- Your stuff goes here -->
    <?php endwhile; ?>
  <?php endif; ?>

To hide multiple category posts at home page, use this below code before the main loop start:

<?php if ( is_home() ) {query_posts( 'cat=-1,-2,-3' ); } ?>

Published by

Emdad Khan

I am Emdad Khan, A WordPress Theme Developer and Author of BN Web Design Website. A full time Freelancer on WordPress Theme Development & Optimization as well as blogger.

Leave a Reply