[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Displays the next and previous post navigation in single posts.
   4   *
   5   * @package WordPress
   6   * @subpackage Twenty_Twenty
   7   * @since Twenty Twenty 1.0
   8   */
   9  
  10  $next_post = get_next_post();
  11  $prev_post = get_previous_post();
  12  
  13  if ( $next_post || $prev_post ) {
  14  
  15      $pagination_classes = '';
  16  
  17      if ( ! $next_post ) {
  18          $pagination_classes = ' only-one only-prev';
  19      } elseif ( ! $prev_post ) {
  20          $pagination_classes = ' only-one only-next';
  21      }
  22  
  23      ?>
  24  
  25      <nav class="pagination-single section-inner<?php echo esc_attr( $pagination_classes ); ?>" aria-label="<?php esc_attr_e( 'Post', 'twentytwenty' ); ?>">
  26  
  27          <hr class="styled-separator is-style-wide" aria-hidden="true" />
  28  
  29          <div class="pagination-single-inner">
  30  
  31              <?php
  32              if ( $prev_post ) {
  33                  ?>
  34  
  35                  <a class="previous-post" href="<?php echo esc_url( get_permalink( $prev_post->ID ) ); ?>">
  36                      <span class="arrow" aria-hidden="true">&larr;</span>
  37                      <span class="title"><span class="title-inner"><?php echo wp_kses_post( get_the_title( $prev_post->ID ) ); ?></span></span>
  38                  </a>
  39  
  40                  <?php
  41              }
  42  
  43              if ( $next_post ) {
  44                  ?>
  45  
  46                  <a class="next-post" href="<?php echo esc_url( get_permalink( $next_post->ID ) ); ?>">
  47                      <span class="arrow" aria-hidden="true">&rarr;</span>
  48                          <span class="title"><span class="title-inner"><?php echo wp_kses_post( get_the_title( $next_post->ID ) ); ?></span></span>
  49                  </a>
  50                  <?php
  51              }
  52              ?>
  53  
  54          </div><!-- .pagination-single-inner -->
  55  
  56          <hr class="styled-separator is-style-wide" aria-hidden="true" />
  57  
  58      </nav><!-- .pagination-single -->
  59  
  60      <?php
  61  }


Generated : Thu Dec 26 08:20:01 2024 Cross-referenced by PHPXref