Hi
In total I want to display 4 posts in which I created 2 loops where the goal of the first loop is to show the 2 latest posts.
The second loop should display 2 posts random, excluding the first 2 of above. This works fine except for one thing:
Instead of displaying 2 posts the second loop leaves the space empty if it selects one post from the first loop. Who can help me solve this issue?
This is my code:
<div id="vids">
<?php $my_query = new WP_Query('cat=-3,-6&posts_per_page=2&orderby=date&order=DESC');?>
<?php while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate[] = $post->ID ?>
<div class="homevideo">
<div class="category">
<?php the_category(' '); ?>
</div>
<div class="videothumb">
<img src="<?php video_thumbnail(); ?>" width="185" height="105" />
</div>
<div class="videoname">
<a href="<?php the_permalink() ?>" > <?php the_title(); ?> </a>
</div>
</div>
<?php endwhile; ?>
<?php $my_newquery = new WP_Query('cat=-3,-6&posts_per_page=2&orderby=rand');?>
<?php while ($my_newquery->have_posts()) : $my_newquery->the_post();
if (in_array($post->ID, $do_not_duplicate)) continue;
?>
<div class="homevideo">
<div class="category">
<?php the_category(' '); ?>
</div>
<div class="videothumb">
<img src="<?php video_thumbnail(); ?>" width="185" height="105" />
</div>
<div class="videoname">
<a href="<?php the_permalink() ?>" > <?php the_title(); ?> </a>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
thanks a lot in advance!
Joost