I have 3 categories,
1.OnGoing projects(cat id=’5′)
2.Completed Projects(cat id=’6′)
3.Upcoming Projects(cat id=’7′)
and also i have another 2 categories:(Not a Sub Category)
-
chennai (cat id=’10’)
-
Dubai (cat id=’11)
How to get the post from “OnGoing Projects” with “Chennai” category?(I like to Display -> OnGoing Projects on Chennai.)
I have tried the following code:
<?php
query_posts('posts_per_page=6&cat=5&cat=10');
while(have_posts()) : the_post();
?><li>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(array(230,192)); ?></a>
</li>
<?php endwhile;
wp_reset_query();
?>
likely To show the “OnGoing Projects” with “Dubai” category? (Ongoing Projects on Dubai)
for this:
<?php
query_posts('posts_per_page=6&cat=5&cat=11');
while(have_posts()) : the_post();
?><li>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(array(230,192)); ?></a>
</li>
<?php endwhile;
wp_reset_query();
?>
This is Not Working Fully.
Please Help me to Figure Out.
Thanks i Advance.
Just guessing here, but I suspect that
query_posts()
is not appropriate in this situation.query_posts()
should only be used to modify the main query, and the emerging best practice is thatquery_posts()
shouldn’t be used at all, but, instead, replaced by filteringpre_get_posts
.Having said all that, I would look into
WP_Query
and particularly thetax_query
argument.Your new snippet will look something like this: