Skip to content

Commit c726a26

Browse files
committed
Twenty Twenty One: 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. git-svn-id: https://develop.svn.wordpress.org/trunk@61091 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 82d47f1 commit c726a26

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/wp-content/themes/twentytwentyone/inc/template-tags.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ function twenty_twenty_one_post_thumbnail() {
219219
* @return void
220220
*/
221221
function twenty_twenty_one_the_posts_navigation() {
222+
$order = get_query_var( 'order', 'DESC' );
223+
$new_posts_text = __( 'Newer <span class="nav-short">posts</span>', 'twentytwentyone' );
224+
$old_posts_text = __( 'Older <span class="nav-short">posts</span>', 'twentytwentyone' );
225+
222226
the_posts_pagination(
223227
array(
224228
'before_page_number' => esc_html__( 'Page', 'twentytwentyone' ) . ' ',
@@ -227,7 +231,7 @@ function twenty_twenty_one_the_posts_navigation() {
227231
'%s <span class="nav-prev-text">%s</span>',
228232
is_rtl() ? twenty_twenty_one_get_icon_svg( 'ui', 'arrow_right' ) : twenty_twenty_one_get_icon_svg( 'ui', 'arrow_left' ),
229233
wp_kses(
230-
__( 'Newer <span class="nav-short">posts</span>', 'twentytwentyone' ),
234+
( 'DESC' === $order ) ? $new_posts_text : $old_posts_text,
231235
array(
232236
'span' => array(
233237
'class' => array(),
@@ -238,7 +242,7 @@ function twenty_twenty_one_the_posts_navigation() {
238242
'next_text' => sprintf(
239243
'<span class="nav-next-text">%s</span> %s',
240244
wp_kses(
241-
__( 'Older <span class="nav-short">posts</span>', 'twentytwentyone' ),
245+
( 'DESC' === $order ) ? $old_posts_text : $new_posts_text,
242246
array(
243247
'span' => array(
244248
'class' => array(),

0 commit comments

Comments
 (0)