Get Adjacent Post – V2 series
This function format has been deprecated, see this post instead Previous Post Link for v3 series. – See more at: Get Adjacent Post
Used on single post permalink pages, this return the post type data to the previous/next post.
This tag 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.
Arguments:
apto_get_adjacent_post ($use_custom_order, $term_id, $taxonomy , $previous);
This function should be used along with a custom query
Parameters
$use_custom_order(boolean) Use the custom defined order
$term_id(int) Specify the term id from where the order will apply
$taxonomy(string) Specify the taxonomy name for the $term_id
$previous(boolean) Return Previous or Next
Examples
Return the previous post data using the custom defined order from within the Archive (all posts).
$post_data = apto_get_adjacent_post( TRUE, FALSE, FALSE, TRUE);
Display the previous post data using the default WordPress order:
$post_data = apto_get_adjacent_post( FALSE, FALSE, FALSE, TRUE);
Display the previous post data using the order specified within categories, through term name ‘News Category’ with id 5
$post_data = apto_get_adjacent_post( TRUE, 5, ‘category’, TRUE);
Display the next post data using the order specified within taxonomy ‘Movies’, within term name ‘Titanic’ with id 10
$post_data = apto_get_adjacent_post( TRUE, ’10’, ‘movies’, FALSE);