0

I have category_id=3 and have 10 post in category_id=3 with post_id= 1=>10

How to show list post category_id=3 with no post_id=1,3,5 value as

query_posts('cat=3& -p=1,3,5 &showposts=30

2 Answers 2

1

If you are trying to omit posts 1,3,5 from category 3 on your blog, you can use the following code

$query = new WP_Query( array('cat' => 3, 'post_type' => 'post', 'post__not_in' => array(1,3,5) ) );

The query results will not show posts with ids 1,3,5 of category 3.

-1

You have placed minus sign before the parameter. This only work for inclusion of post.

For exclusion you have to use like this

query_posts(array('posts_per_page' => 10, 'post__not_in' => array(1,3,5)));

Check this in Wordpress Codex

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.