navigation.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. $next_post = get_next_post();
  10. $prev_post = get_previous_post();
  11. if ( $next_post || $prev_post ) {
  12. $pagination_classes = '';
  13. if ( ! $next_post ) {
  14. $pagination_classes = ' only-one only-prev';
  15. } elseif ( ! $prev_post ) {
  16. $pagination_classes = ' only-one only-next';
  17. }
  18. ?>
  19. <nav class="pagination-single section-inner<?php echo esc_attr( $pagination_classes ); ?>" aria-label="<?php esc_attr_e( 'Post', 'twentytwenty' ); ?>" role="navigation">
  20. <hr class="styled-separator is-style-wide" aria-hidden="true" />
  21. <div class="pagination-single-inner">
  22. <?php
  23. if ( $prev_post ) {
  24. ?>
  25. <a class="previous-post" href="<?php echo esc_url( get_permalink( $prev_post->ID ) ); ?>">
  26. <span class="arrow" aria-hidden="true">&larr;</span>
  27. <span class="title"><span class="title-inner"><?php echo wp_kses_post( get_the_title( $prev_post->ID ) ); ?></span></span>
  28. </a>
  29. <?php
  30. }
  31. if ( $next_post ) {
  32. ?>
  33. <a class="next-post" href="<?php echo esc_url( get_permalink( $next_post->ID ) ); ?>">
  34. <span class="arrow" aria-hidden="true">&rarr;</span>
  35. <span class="title"><span class="title-inner"><?php echo wp_kses_post( get_the_title( $next_post->ID ) ); ?></span></span>
  36. </a>
  37. <?php
  38. }
  39. ?>
  40. </div><!-- .pagination-single-inner -->
  41. <hr class="styled-separator is-style-wide" aria-hidden="true" />
  42. </nav><!-- .pagination-single -->
  43. <?php
  44. }