You can do this by using filters in the get_adjacent_post
function.
In your functions.php file, add:
function mytheme_previous_post_orderby_name($orderby){
return "ORDER BY p.post_title DESC LIMIT 1";
}
function mytheme_previous_post_where_name(){
global $post, $wpdb;
return $wpdb->prepare( "WHERE p.post_title < %s AND p.post_type = %s AND ( p.post_status = 'publish' OR p.post_status = 'private' )", $post->post_title, $post->post_type );
}
function mytheme_next_post_orderby_name($orderby){
return "ORDER BY p.post_title ASC LIMIT 1";
}
function mytheme_next_post_where_name(){
global $post, $wpdb;
return $wpdb->prepare( "WHERE p.post_title > %s AND p.post_type = %s AND ( p.post_status = 'publish' OR p.post_status = 'private' )", $post->post_title, $post->post_type );
}
Then in your single.php page add the filters before you call the previous/next posts link functions:
add_filter('get_previous_post_sort', 'mytheme_previous_post_orderby_name', 10, 1);
add_filter('get_next_post_sort', 'mytheme_next_post_orderby_name', 10, 1);
add_filter('get_previous_post_where', 'mytheme_previous_post_where_name', 10);
add_filter('get_next_post_where', 'mytheme_next_post_where_name', 10);
the_post_navigation();
remove_filter('get_previous_post_sort', 'mytheme_previous_post_orderby_name', 10);
remove_filter('get_next_post_sort', 'mytheme_next_post_orderby_name', 10);
remove_filter('get_previous_post_where', 'mytheme_previous_post_where_name', 10);
remove_filter('get_next_post_where', 'mytheme_next_post_where_name', 10);
If you want to check for your specific post_type, you can add an if around the adding filter section:
if($post->post_type == 'my_custom_post_type'){
add_filter(...);
the_post_navigation();
remove_filter(...);
}
or, you can just use a post_type specific single.php file!
This worked great for me, but there may be some limitations if you are planning on combining this with posts in the same term...