Here’s a handy little patch that snuck into WordPress 3.8…
Up until now the previous_post_link() and next_post_link() WordPress functions have just had a paramter $in_same_cat which if true returns a link to the previous/next post in the same category as the current post.
In WordPress 3.8 that is now a new $taxonomy parameter which allows you to specify a custom taxonomy rather that a category. This will be immensely useful to anyone who uses custom taxonomies and custom post types.
As an example, WordPress Post Formats are actually a custom taxonomy so you could use the following code to output a link to the same post with the same post format as the current post:
<?php next_post_link( '%link', 'Next post in category', TRUE, ' ', 'post_format' ); ?> |
This update affects all the following functions:
get_previous_post(), get_next_post(), get_adjacent_post(), get_adjacent_post_rel_link(), adjacent_posts_rel_link(), next_post_rel_link(), prev_post_rel_link(), get_boundary_post(), get_previous_post_link(), previous_post_link(), get_next_post_link(), next_post_link(), get_adjacent_post_link(), adjacent_post_link()