deadlycomputer
Member
Posted 2 years ago #
Here's my situation:
I have a category - Work.
In that category are 20 or so posts currently.
I have them displayed alphabetically on that category page all fine.
My problem is this:
When I click on the post, and view it's page, the next/previous links are in chronological order.
How can I get those in alphabetical order?
deadlycomputer
Member
Posted 2 years ago #
well, I was able to make a custom function to do what i wanted:
function nextLinks($tp)
{
$wp2 = array();
$i=0;
$pOrder = array(
'category_name' => 'work',
'orderby' => 'title',
'order' => 'ASC',
'nopaging' => true,
'posts_count' => 5
);
$workPosts = get_posts($pOrder);
foreach($workPosts as $wpost)
{
$pid = $wpost->ID;
$wp2[$i] = $pid;
$i++;
}
$pnum = array_search($tp,$wp2);
if($pnum-1 >= 0)
{
$pre = '<a href="'.get_permalink($wp2[$pnum-1]).'" title="'.get_the_title($wp2[$pnum-1]).'" class="floatLeft"><'.get_the_title($wp2[$pnum-1]).'</a>';
}
if($pnum+1 < count($wp2))
{
$nxt = '<a href="'.get_permalink($wp2[$pnum+1]).'" title="'.get_the_title($wp2[$pnum+1]).'" class="rightArrow">'.get_the_title($wp2[$pnum+1]).'></a>';
}
echo $pre . $nxt;
}
if there's a simpler, or built in way to do what i want i'd love to know
Just found a plugin which does this and also provides more customisation features for Next/Previous links. It's called 'Next/Previous Post Links Plus' and it's by Ambrosite.
http://www.ambrosite.com/plugins/next-previous-post-link-plus-for-wordpress