I am pulling 5 random posts and i didn't want it to show the current post in this loop, so here is how to do it:
<?php
global $wp_query;
$thePostID = $wp_query->post->ID;
$rand_posts = get_posts('numberposts=5&exclude='.$thePostID.'&orderby=rand');
foreach( $rand_posts as $post ) :?>
<h3><?php the_title(); ?></h3>
<?php endforeach; ?>
enailor
Member
Posted 3 years ago #
Let's say I want to have 2 loops... the first one displays the most recent 5 posts, the second a random selection of posts; however I want the most recent 5 to be excluded from the second loop. How would you go about doing that?
Dunkkan
Member
Posted 2 years ago #
Hey, excellent ! Thanks very much for this.