Make WordPress Core

Changeset 61092


Ignore:
Timestamp:
10/30/2025 06:19:11 PM (4 weeks ago)
Author:
joedolson
Message:

Twenty Twenty: Fix post navigation to respect sort order.

Change the labels on post navigation links when the sort order is changed so the labels accurately reflect the target entries.

Previously, if the sort order was reversed, 'Older' or 'Previous' links would navigate to newer entries and 'Newer' or 'Next' links would navigate to older entries.

Props jikamens, dancameron, obenland, shrey0shrivastava, sirlouen, sabernhardt, shailu25, joedolson.
See #10219.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentytwenty/template-parts/pagination.php

    r57276 r61092  
    1010 */
    1111
     12$order = get_query_var( 'order', 'DESC' );
     13
     14/*
     15 * Translators: This text contains HTML to allow the text to be shorter on small screens.
     16 * The text inside the span with the class nav-short will be hidden on small screens.
     17 */
     18$new_posts_text = __( 'Newer <span class="nav-short">Posts</span>', 'twentytwenty' );
     19
     20/*
     21 * Translators: This text contains HTML to allow the text to be shorter on small screens.
     22 * The text inside the span with the class nav-short will be hidden on small screens.
     23 */
     24$old_posts_text = __( 'Older <span class="nav-short">Posts</span>', 'twentytwenty' );
     25
    1226$prev_text = sprintf(
    1327    '%s <span class="nav-prev-text">%s</span>',
    1428    '<span aria-hidden="true">&larr;</span>',
    15     /*
    16      * Translators: This text contains HTML to allow the text to be shorter on small screens.
    17      * The text inside the span with the class nav-short will be hidden on small screens.
    18      */
    19     __( 'Newer <span class="nav-short">Posts</span>', 'twentytwenty' )
     29    ( 'DESC' === $order ) ? $new_posts_text : $old_posts_text
    2030);
    2131$next_text = sprintf(
    2232    '<span class="nav-next-text">%s</span> %s',
    23     /*
    24      * Translators: This text contains HTML to allow the text to be shorter on small screens.
    25      * The text inside the span with the class nav-short will be hidden on small screens.
    26      */
    27     __( 'Older <span class="nav-short">Posts</span>', 'twentytwenty' ),
     33    ( 'DESC' === $order ) ? $old_posts_text : $new_posts_text,
    2834    '<span aria-hidden="true">&rarr;</span>'
    2935);
Note: See TracChangeset for help on using the changeset viewer.