A plugin for developers, WP_Query Powered Adjacent Post Link gives developers previous and next post buttons based on WP_Query arguments.
$post_id Pass the current post ID so the function knows what to check adjacency relative to. (required)
$args Pass arguments which will be fed directly into the WP_Query class. Be alert for errors which occur at this step as not all errors are handled by the plugin. (required)
$adj Pass either 'previous' or 'next'. You get the idea. (required)
$return Pass what you want returned. Pass nothing and the function will return the entire post object for the adjacency you have selected. The string can be any of the following: - "ID" - "title" - "slug" - "permalink"
The plugin always returns information, so use it in conjunction with
echo(); in your theme.
In this example I gather the permalink to the previous post while specifying arguments for a WP_Query result which matches the desired results.
$args = array( 'post_type' => 'my_custom_post_type', 'orderby' => 'menu_order' ); $previous_post_link = wpqpapl($post->ID,$args,'previous','permalink');