Don’t show a WordPress category on posts page

by Steph on September 17, 2009

Have you ever used WordPress posts for something other than a blog post? I use them for FAQ pages, but I don’t want the FAQs to show up in the main blog.

(?? = category id number)

function exclude_category($query) {
  if ( $query->is_home )
    $query->set('cat', '-??');
  return $query;
}
add_filter('pre_get_posts', 'exclude_category');

The minus sign in front of the category id means don’t include.

DiggTwitterFacebookLinkedIn

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post:

Next post: