Documentation - How To - Get Adjacent Post

Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInPrint this page

Get Adjacent Post

Used on single post permalink pages, this return the post type data to the previous/next post.

This function must be used in The Loop.

The default WordPress function for this is get_adjacent_post however this procedure is very restrictive with the custom order and the terms/taxonomies where to apply.

An improved version is apto_get_adjacent_post function. This function should be used along with a custom query

Format:
apto_get_adjacent_post ($argv , $previous);

Parameters
$argv(array) List of function arguments:

sort_id – the sort id which order will be used
taxonomy – use the specified sort taxonomy
term_id – use the specified sort taxonomy term

$previous(boolean) Return Previous or Next

Examples

Return previous post using order from taxonomy ‘Features’ within term_id 10

$args   =   array(
                        'sort_id'   =>  25,
                            'taxonomy'  =>  'features',
                            'term_id'   =>  10
                        );
$post_data = apto_get_adjacent_post($args, TRUE);
if($post_data !== FALSE)
  echo $post_data->post_title;