$posts = query_posts(array('post_type'=>'sedan', 'category'=>'1', 'posts_per_page'=>'4'));
The category
parameter in the above query doesn’t seem to work as expected. It is showing all the posts from Sedan
post type, but I want to specify only categories with category ID = 1
within Sedan post type
.
Try with
cat
instead ofcategory
.Also don’t use
query_posts()
for your query.https://codex.wordpress.org/Function_Reference/query_posts
Use
get_posts()
orWP_Query()
You can achieve the same with:
Safer way then modifying the main query.
I always prefer
WP_Query
myself.try to use
get_posts
refrenceor another option is to use
WP_Query
or with cat id
This is what worked for me.