As an update to the previous post. Formatting is all sorted but there is one last issue... and it's the ordering.
With this:
<?php
//for use in single.php (if used other places need to set $currentid)
//get all posts and then display certain number ($num_old_new) of posts dated before this post, and same number of posts dated after this post.
//
$num_old_new = 5; // max number of older posts to show. Also will be max number of newer posts to show.
$newer_title = '<p class="single top">Next';
$older_title = '</p><p class="single top">Previously';
$currentid = $posts[0]->ID;
$thisone = 0;
$args=array(
'orderby' => 'date',
'order' => 'ASC',
'post_type' => 'post',
'post_status' => 'publish',
'showposts'=>-1,
'caller_get_posts'=>1
);
$allposts = get_posts($args);
if ($allposts) {
for ( $counter = 0; $counter <= count($allposts); $counter += 1) {
if ( $allposts[$counter]->ID == $currentid ) {
$thisone = $counter;
}
}
$begin = 0;
$end = count($allposts) - 1;
if ( $thisone - $num_old_new >= $begin ) {
$begin = $thisone - $num_old_new;
}
if ( $thisone + $num_old_new <= $end ) {
$end = $thisone + $num_old_new;
}
for ( $counter = $begin; $counter <= $end; $counter += 1) {
if ( $allposts[$counter]->ID != $currentid ) {
$post = $allposts[$counter];
setup_postdata($post);
if ( $counter > $thisone && $newer_title ){ //display newer title once
echo $newer_title;
$newer_title = '';
}
if ( $counter < $thisone && $older_title ){ //display older title once
if (!$newer_title) { } else {$older_title = '<p class="single top">Previously';}
echo $older_title;
$older_title = '';
}
?> • " rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?><?php
}
}
}
?></p>
<?php wp_reset_query(); //just in case
?>
It orders the "Next" correctly but "Previous" is sorted in reverse chronological, the previous post is the furthers to the right instead of being next to the title "Previous".
Any ideas on how to sort that out or is it a flaw with how it's all done?
Any idea how to separate the two objectives? Having one do Next ordered in ascending and Previous ordered in descending?