single.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * The template for displaying all single posts
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
  6. *
  7. * @package WordPress
  8. * @subpackage Twenty_Twenty_One
  9. * @since Twenty Twenty-One 1.0
  10. */
  11. get_header();
  12. /* Start the Loop */
  13. while ( have_posts() ) :
  14. the_post();
  15. get_template_part( 'template-parts/content/content-single' );
  16. if ( is_attachment() ) {
  17. // Parent post navigation.
  18. the_post_navigation(
  19. array(
  20. /* translators: %s: Parent post link. */
  21. 'prev_text' => sprintf( __( '<span class="meta-nav">Published in</span><span class="post-title">%s</span>', 'twentytwentyone' ), '%title' ),
  22. )
  23. );
  24. }
  25. // If comments are open or there is at least one comment, load up the comment template.
  26. if ( comments_open() || get_comments_number() ) {
  27. comments_template();
  28. }
  29. // Previous/next post navigation.
  30. $twentytwentyone_next = is_rtl() ? twenty_twenty_one_get_icon_svg( 'ui', 'arrow_left' ) : twenty_twenty_one_get_icon_svg( 'ui', 'arrow_right' );
  31. $twentytwentyone_prev = is_rtl() ? twenty_twenty_one_get_icon_svg( 'ui', 'arrow_right' ) : twenty_twenty_one_get_icon_svg( 'ui', 'arrow_left' );
  32. $twentytwentyone_next_label = esc_html__( 'Next post', 'twentytwentyone' );
  33. $twentytwentyone_previous_label = esc_html__( 'Previous post', 'twentytwentyone' );
  34. the_post_navigation(
  35. array(
  36. 'next_text' => '<p class="meta-nav">' . $twentytwentyone_next_label . $twentytwentyone_next . '</p><p class="post-title">%title</p>',
  37. 'prev_text' => '<p class="meta-nav">' . $twentytwentyone_prev . $twentytwentyone_previous_label . '</p><p class="post-title">%title</p>',
  38. )
  39. );
  40. endwhile; // End of the loop.
  41. get_footer();