Make WordPress Core

Changeset 34715


Ignore:
Timestamp:
09/30/2015 03:40:52 AM (10 years ago)
Author:
DrewAPicture
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/link-template.php

    r34690 r34715  
    23382338 *
    23392339 * @since 4.1.0
     2340 * @since 4.4.0 Introduced the `in_same_term`, `excluded_terms`, and `taxonomy` arguments.
    23402341 *
    23412342 * @param array $args {
    23422343 *     Optional. Default post navigation arguments. Default empty array.
    23432344 *
    2344  *     @type string $prev_text          Anchor text to display in the previous post link. Default `%title`.
    2345  *     @type string $next_text          Anchor text to display in the next post link. Default `%title`.
    2346  *     @type string $screen_reader_text Screen reader text for nav element. Default 'Post navigation'.
     2345 *     @type string       $prev_text          Anchor text to display in the previous post link. Default '%title'.
     2346 *     @type string       $next_text          Anchor text to display in the next post link. Default '%title'.
     2347 *     @type bool         $in_same_term       Whether link should be in a same taxonomy term. Default false.
     2348 *     @type array|string $excluded_terms     Array or comma-separated list of excluded term IDs. Default empty.
     2349 *     @type string       $taxonomy           Taxonomy, if `$in_same_term` is true. Default 'category'.
     2350 *     @type string       $screen_reader_text Screen reader text for nav element. Default 'Post navigation'.
    23472351 * }
    23482352 * @return string Markup for post links.
     
    23522356        'prev_text'          => '%title',
    23532357        'next_text'          => '%title',
     2358        'in_same_term'       => false,
     2359        'excluded_terms'     => '',
     2360        'taxonomy'           => 'category',
    23542361        'screen_reader_text' => __( 'Post navigation' ),
    23552362    ) );
    23562363
    23572364    $navigation = '';
    2358     $previous   = get_previous_post_link( '<div class="nav-previous">%link</div>', $args['prev_text'] );
    2359     $next       = get_next_post_link( '<div class="nav-next">%link</div>', $args['next_text'] );
     2365
     2366    $previous = get_previous_post_link(
     2367        '<div class="nav-previous">%link</div>',
     2368        $args['prev_text'],
     2369        $args['in_same_term'],
     2370        $args['excluded_terms'],
     2371        $args['taxonomy']
     2372    );
     2373
     2374    $next = get_next_post_link(
     2375        '<div class="nav-next">%link</div>',
     2376        $args['next_text'],
     2377        $args['in_same_term'],
     2378        $args['excluded_terms'],
     2379        $args['taxonomy']
     2380    );
    23602381
    23612382    // Only add markup if there's somewhere to navigate to.
Note: See TracChangeset for help on using the changeset viewer.