How to Exclude a category from WP_Query in WordPress !

exclude category from wp query

Exclude Category .. Sometime we don’t want to show the posts from the particular category so here is the code you have to modify..

query_posts(array(
'post_type' => 'post',
'showposts' => 14,
'category__not_in' => 10, // category id
) );

In the above code you can find ID of that category in dashboard and can apply here..in place of 10 highlighted.

If you want to leave posts from more than 1 category then you can apply this code there..

query_posts(array(
'post_type' => 'post',
'showposts' => 14,
'category__not_in' => array(6,10), // category id's
) );


For any help contact me here..


If this help you then.. Can you buy a Cup of Coffee for me by nst webcreation paypal--OR-- nst webcreation blog coffee cup

Published by

NST

Myself Narender Singh Thakur ( NST ) and i share my Experience/Knowledge and Tricks for folks and beginners to solve their issues while making websites through this Planet.

Related Articles

Leave a Reply

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

Click to Chat