get_next_post_link
Retrieves the next post link that is adjacent to the current post.
Description
(string) get_next_post_link( , , (constant) $in_same_term = false, (string) $excluded_terms = '', (string) $taxonomy = 'category' );
Returns (string)
The link URL of the next post in relation to the current post.
Parameters (5)
- 0. $format — Optional. (string) =>
'%link »'
- Link anchor format. Default « %link..
- 1. $link — Optional. (string) =>
'%title'
- Link permalink format. Default %title..
- 2. $in_same_term — Optional. (constant) =>
false
- Whether link should be in a same taxonomy term. Default false.
- 3. $excluded_terms — Optional. (string) =>
''
- Array or comma-separated list of excluded term IDs. Default empty.
- 4. $taxonomy — Optional. (string) =>
'category'
- Taxonomy, if
$in_same_term
is true. Default category..
Usage
if ( !function_exists( 'get_next_post_link' ) ) { require_once ABSPATH . WPINC . '/link-template.php'; } // Optional. Link anchor format. Default '« %link'. $format = '%link »'; // Optional. Link permalink format. Default '%title'. $link = '%title'; // Optional. Whether link should be in a same taxonomy term. Default false. $in_same_term = false; // Optional. Array or comma-separated list of excluded term IDs. Default empty. $excluded_terms = ''; // Optional. Taxonomy, if $in_same_term is true. Default 'category'. $taxonomy = 'category'; // NOTICE! Understand what this does before running. $result = get_next_post_link($format, $link, $in_same_term, $excluded_terms, $taxonomy);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/link-template.php
- function get_next_post_link( $format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
- return get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, false, $taxonomy );
- }