Languages: English • 日本語 (Add your language)
Used on single post permalink pages, this template tag displays a link to the previous post which exists in chronological order from the current post.
This tag must be used in The Loop.
<?php previous_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ); ?>
Displays link with left angular quote («) followed by the post title of the previous post (chronological post date order).
<?php previous_post_link(); ?>
Displays link with previous chronological post's title wrapped in 'strong' tags (typically sets text to bold).
<?php previous_post_link('<strong>%link</strong>'); ?>
Displays custom text as link to the previous post within the same category as the current post. Post title is not included here. "Previous in category" is the custom text, which can be changed to fit your requirements.
<?php previous_post_link('%link', 'Previous in category', TRUE); ?>
Displays link to previous post in the same category, as long as it is not in category 13 (the category ID #). You can change the number to any category you wish to exclude. Array or comma-separated list of category ID(s) from which the previous post should not be listed. For example array( 1, 5) or '1,5'.
<?php previous_post_link('%link', 'Previous in category', TRUE, '13'); ?>
Displays link to previous post in the same taxonomy term. Post Formats are a taxonomy so the following would link to the previous post with the same post format.
<?php previous_post_link( '%link', 'Previous post in category', TRUE, ' ', 'post_format' ); ?>
Displays link to previous post in the same custom taxonomy term. You have a Custom Post Type called Buildings, and a custom taxonomy called Neighborhood. Here you don't need to use the Custom Post Type( as Custom Post Type already in the WP query). Just mention the taxonomy name(which is neighborhood as per this example) as last parameter of previous_post_link function.
<?php previous_post_link( '%link', '%title', TRUE, ' ', 'neighborhood' ); ?>
previous_post_link() is located in wp-includes/link-template.php
.