How To Hide a WordPress Category Posts

Sometimes, We nned to display certain posts on your WordPress powered site and some time you may need to hide speciffic categories Posts from posts pages.

So for hide specifice category posts from post page or other page.To do this, enter the following lines above the Loop (In page template or in post page template):

1
2
<?php if (is_front_page() && !is_paged()
) $posts = query_posts($query_string . '&cat=-7,-57'); ?>

This prevents posts from categories 7 and 57 from appearing in the list of posts.

Leave a Reply