Wordpress show next 3 x number adjacent custom posts from existing

Posted by user2463284 on Stack Overflow See other posts from Stack Overflow or by user2463284
Published on 2014-08-18T11:15:21Z Indexed on 2014/08/19 10:20 UTC
Read the original article Hit count: 196

On a single/detail Custom Post Page I would like to display a custom nav of li's or divs in a sidebar that displays both title, excerpt and permalink for the next 3 posts within the custom post series. So if we are on custom post 3 then it would show 4, 5, 6 in the sidebar.

The closest I've found to this is :-=

global $post;
$current_post = $post; // remember the current post

for($i = 1; $i <= 3; $i++){
 $post = get_previous_post(); // this uses $post->ID
setup_postdata($post);

// do your stuff here       
the_title();

}

$post = $current_post; // restore

Problem is this only shows the first next post and I need to show 3.

Thanks Glennyboy

© Stack Overflow or respective owner

Related posts about Wordpress

Related posts about navigation