< ?php /* Run the loop to output the post. * If you want to overload this in a child theme then include a file * called loop-single.php and that will be used instead. */ if(have_posts()) while(have_posts()): the_post(); the_title(); for($i = 0;$i < 4;$i++) { $post = get_next_post(); setup_postdata($post); if(!empty($post)) { echo '
'; the_title(); //or whatever code you need to output } else { //no next post found } } endwhile; wp_reset_postdata(); ?>