Query posts category not in question
-
Hey guys,
I’m using query posts to show the 5 most recent posts on my homepage. I want to exclude all posts that are in a certain category and any of its child categories. At the moment im using the ‘category_not_in’ tag but this only works if i put in the id of both the parent and all its child categories. This is cumbersome as if i add a child category i have to go into the editor and add the id into the array. Is there a tag that tells wordpress to exclude all posts of a certain category and its child categories??
My current code is as follows, with 31 being the id of the parent, and 32 and 33 the child categories.
Thanks.
<?php query_posts(array(‘category__not_in’ => array( 31, 32, 33 ),’showposts’=>5 )); ?>
- The topic ‘Query posts category not in question’ is closed to new replies.