Wordpress How to exclude any category post to being display


2 Votes, Rating: 51 Star2 Stars3 Stars4 Stars5 Stars

Tags: ,

Exclude/Stop any category posts to displayed on any page

As wordpress being used as CMS now a days, we need many trick to use it properly, coz our requirement are different each time when we develope any new site with WP.

Some time we dont want to show any particular category post on home page. or any other page, so this trick & hack best for you.

Exclude Posts in WP

Search this code

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

Replace with

<?php
if ( have_posts() ) : query_posts($query_string .'&amp;cat=-1,-2'); while ( have_posts() ) : the_post();
?>

cat=-1,-2  = these are category Id’s

you can also add numbers of post you want to show by using these trick

<?php
if ( have_posts() ) : query_posts($query_string .'&amp;cat=-1,-2&amp;showposts=2&amp;order=asc'); while ( have_posts() ) : the_post();
?>

showposts= number of post you want to display,

Order by = its upto you to show ASC/DESC

Share/Save/Bookmark

Leave a Reply