Hey Jirikai,
I had a similar need and ended up discovering that this really needs a custom query to make it happen. I’ve never made a plugin, so I’m sure this could be plugin-ized, but I didn’t pursue that.
This looks at a value passed in the URL and saved to the variable $val to see if this is a “list” or “thumbnail” view. If it’s a list, then the next link is the next one alphabetically, if it’s a thumbnail, then the next link is the previous post chronologically.
There’s a little extra complexity here b/c it’s also limiting them to be within a single category.
<?php
$category = 'projects'; //limit results only to projects
$currentPostTitle = $wpdb->escape($post->post_title); //get the Title of the current post, escape it b/c some titles have special characters
$currentPostDate = $post->post_date; //get the date of the current post
if ($val == "list") { $threshold = "AND p.post_title > '$currentPostTitle'"; $sortByNext = "p.post_title ASC" ;} else { $threshold = "AND p.post_date < '$currentPostDate'"; $sortByNext = "p.post_date DESC" ;} // evaluate view value and set sort order depending on alpha (list) or chronological (thumb)
$querystr = "
SELECT p.* from $wpdb->posts p, $wpdb->terms t, $wpdb->term_taxonomy tt, $wpdb->term_relationships tr, $wpdb->terms t2, $wpdb->term_taxonomy tt2, $wpdb->term_relationships tr2
WHERE p.id = tr.object_id
AND t.term_id = tt.term_id
AND tr.term_taxonomy_id = tt.term_taxonomy_id
AND p.id = tr2.object_id
AND t2.term_id = tt2.term_id
AND tr2.term_taxonomy_id = tt2.term_taxonomy_id
AND (tt.taxonomy = 'category' AND tt.term_id = t.term_id AND t.slug = '$category')
AND p.post_status = 'publish'
$threshold
ORDER BY $sortByNext
LIMIT 1
";
$pagePostsNext = $wpdb->get_results($querystr, OBJECT);
?>
<?php if ($pagePostsNext): ?>
<?php foreach ($pagePostsNext as $postNext): ?>
<a href="<?php bloginfo('url'); ?>/<?php echo $postNext->post_name; ?>?<?php if (isset($val)) echo 'view=' . $val; ?><?php if (isset($keyword)) echo '&keyword=' . $keyword; ?><?php if (isset($side)) echo "&side=" . "$side";?>">Next project</a>
<?php endforeach; ?>
<?php else : ?>
<?php endif; ?>