I'd like to query posts by taxonomy like this:
<?php
global $post;
$terms = get_the_terms( $post->ID , 'movies', 'string');
$do_not_duplicate[] = $post->ID;
if(!empty($terms)){
foreach ($terms as $term) {
query_posts( array(
'movies' => $term->slug,
'showposts' => 4,
'caller_get_posts' => 1,
'post__not_in' => $do_not_duplicate ) );
if(have_posts()){
while ( have_posts() ) : the_post(); $do_not_duplicate[] = $post->ID; ?>
do stuff
<?php endwhile; wp_reset_query();
}
}
}
?>
But I only want to show this, while there are posts with the same taxonomy to show up.
How could I do this?
Something like: if has taxonomy AND has post?
Thanks!
AD
get_the_termswill return terms that belong to this post - and so it follows each term has at least one post associated to it :) – Stephen Harris Jul 3 '12 at 0:03