[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-content/themes/twentytwenty/template-parts/ -> pagination.php (source)

   1  <?php
   2  /**
   3   * A template partial to output pagination for the Twenty Twenty default theme.
   4   *
   5   * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
   6   *
   7   * @package WordPress
   8   * @subpackage Twenty_Twenty
   9   * @since Twenty Twenty 1.0
  10   */
  11  
  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  
  26  $prev_text = sprintf(
  27      '%s <span class="nav-prev-text">%s</span>',
  28      '<span aria-hidden="true">&larr;</span>',
  29      ( 'DESC' === $order ) ? $new_posts_text : $old_posts_text
  30  );
  31  $next_text = sprintf(
  32      '<span class="nav-next-text">%s</span> %s',
  33      ( 'DESC' === $order ) ? $old_posts_text : $new_posts_text,
  34      '<span aria-hidden="true">&rarr;</span>'
  35  );
  36  
  37  $posts_pagination = get_the_posts_pagination(
  38      array(
  39          'mid_size'  => 1,
  40          'prev_text' => $prev_text,
  41          'next_text' => $next_text,
  42      )
  43  );
  44  
  45  // If we're not outputting the previous page link, prepend a placeholder with `visibility: hidden` to take its place.
  46  if ( false === strpos( $posts_pagination, 'prev page-numbers' ) ) {
  47      $posts_pagination = str_replace( '<div class="nav-links">', '<div class="nav-links"><span class="prev page-numbers placeholder" aria-hidden="true">' . $prev_text . '</span>', $posts_pagination );
  48  }
  49  
  50  // If we're not outputting the next page link, append a placeholder with `visibility: hidden` to take its place.
  51  if ( false === strpos( $posts_pagination, 'next page-numbers' ) ) {
  52      $posts_pagination = str_replace( '</div>', '<span class="next page-numbers placeholder" aria-hidden="true">' . $next_text . '</span></div>', $posts_pagination );
  53  }
  54  
  55  if ( $posts_pagination ) { ?>
  56  
  57      <div class="pagination-wrapper section-inner">
  58  
  59          <hr class="styled-separator pagination-separator is-style-wide" aria-hidden="true" />
  60  
  61          <?php echo $posts_pagination; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- already escaped during generation. ?>
  62  
  63      </div><!-- .pagination-wrapper -->
  64  
  65      <?php
  66  }


Generated : Wed Apr 15 08:20:10 2026 Cross-referenced by PHPXref