Really Simple WordPress Post Filtering

Sometimes you don’t want to show every post category on your WordPress site home page, or any WordPress for that matter.

Luckily there is a really simple way of filtering posts. For example if I want to exclude certain categories from the home page, I could do the following…

if (is_front_page()) {
	query_posts($query_string . '&cat=-101,-1');
}
if (have_posts()) : while (have_posts()) : the_post();
...

Where 101 and 1 are the categories you want to exclude.

Author: Kieran Barnes

Kieran is a PHP developer with 15 years commercial experience. Specialist in WordPress, CakePHP, CubeCart and all things PHP.

Leave a Reply

Your email address will not be published. Required fields are marked *