Assuming the category is A
, there are a sub category of it say subA
which includes a post postinsubA
Then when i use get_posts('category=A&...')
, all posts under category A
also postinsubA
are returned, but i don’t wanna postinsubA
, how can i exclude these posts in sub categories?
Looking at the WordPress manual, there is the query_posts() function that does have a parameter that might work for you.
Here is an example to pull only posts from category 129, but from none of the children categories of 129:
You can also add more categories to it, like array(128,129). I did a quick test on one of my own WordPress blog where the parent (129) had 2 posts, and the child (139) had 1 post. In printing out the loop, only the 2 posts in category 129 displayed.