Themes: Introduce three new arguments for `get_the_post_navigation()`, `in_same_term`, `excluded_terms`, and `taxonomy`.
The addition of these new arguments brings `get_the_post_navigation()` into argument parity with `get_previous_post_link()` and `get_next_post_link()`, both of which it wraps, and will allow for more flexibility in configuring the next and previous post links for simultaneous display in themes. Props ChaseWiseman. Fixes #32618. Built from https://develop.svn.wordpress.org/trunk@34715 git-svn-id: http://core.svn.wordpress.org/trunk@34679 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5ec1077a38
commit
85eafd7632
|
@ -2337,13 +2337,17 @@ function posts_nav_link( $sep = '', $prelabel = '', $nxtlabel = '' ) {
|
|||
* Return navigation to next/previous post when applicable.
|
||||
*
|
||||
* @since 4.1.0
|
||||
* @since 4.4.0 Introduced the `in_same_term`, `excluded_terms`, and `taxonomy` arguments.
|
||||
*
|
||||
* @param array $args {
|
||||
* Optional. Default post navigation arguments. Default empty array.
|
||||
*
|
||||
* @type string $prev_text Anchor text to display in the previous post link. Default `%title`.
|
||||
* @type string $next_text Anchor text to display in the next post link. Default `%title`.
|
||||
* @type string $screen_reader_text Screen reader text for nav element. Default 'Post navigation'.
|
||||
* @type string $prev_text Anchor text to display in the previous post link. Default '%title'.
|
||||
* @type string $next_text Anchor text to display in the next post link. Default '%title'.
|
||||
* @type bool $in_same_term Whether link should be in a same taxonomy term. Default false.
|
||||
* @type array|string $excluded_terms Array or comma-separated list of excluded term IDs. Default empty.
|
||||
* @type string $taxonomy Taxonomy, if `$in_same_term` is true. Default 'category'.
|
||||
* @type string $screen_reader_text Screen reader text for nav element. Default 'Post navigation'.
|
||||
* }
|
||||
* @return string Markup for post links.
|
||||
*/
|
||||
|
@ -2351,12 +2355,29 @@ function get_the_post_navigation( $args = array() ) {
|
|||
$args = wp_parse_args( $args, array(
|
||||
'prev_text' => '%title',
|
||||
'next_text' => '%title',
|
||||
'in_same_term' => false,
|
||||
'excluded_terms' => '',
|
||||
'taxonomy' => 'category',
|
||||
'screen_reader_text' => __( 'Post navigation' ),
|
||||
) );
|
||||
|
||||
$navigation = '';
|
||||
$previous = get_previous_post_link( '<div class="nav-previous">%link</div>', $args['prev_text'] );
|
||||
$next = get_next_post_link( '<div class="nav-next">%link</div>', $args['next_text'] );
|
||||
|
||||
$previous = get_previous_post_link(
|
||||
'<div class="nav-previous">%link</div>',
|
||||
$args['prev_text'],
|
||||
$args['in_same_term'],
|
||||
$args['excluded_terms'],
|
||||
$args['taxonomy']
|
||||
);
|
||||
|
||||
$next = get_next_post_link(
|
||||
'<div class="nav-next">%link</div>',
|
||||
$args['next_text'],
|
||||
$args['in_same_term'],
|
||||
$args['excluded_terms'],
|
||||
$args['taxonomy']
|
||||
);
|
||||
|
||||
// Only add markup if there's somewhere to navigate to.
|
||||
if ( $previous || $next ) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.4-alpha-34714';
|
||||
$wp_version = '4.4-alpha-34715';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue