single.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * The template for displaying all single posts and attachments
  4. *
  5. * @package WordPress
  6. * @subpackage Twenty_Sixteen
  7. * @since Twenty Sixteen 1.0
  8. */
  9. get_header(); ?>
  10. <div id="primary" class="content-area">
  11. <main id="main" class="site-main" role="main">
  12. <?php
  13. // Start the loop.
  14. while ( have_posts() ) : the_post();
  15. // Include the single post content template.
  16. get_template_part( 'template-parts/content', 'single' );
  17. // If comments are open or we have at least one comment, load up the comment template.
  18. if ( comments_open() || get_comments_number() ) {
  19. comments_template();
  20. }
  21. if ( is_singular( 'attachment' ) ) {
  22. // Parent post navigation.
  23. the_post_navigation( array(
  24. 'prev_text' => _x( '<span class="meta-nav">Published in</span><span class="post-title">%title</span>', 'Parent post link', 'twentysixteen' ),
  25. ) );
  26. } elseif ( is_singular( 'post' ) ) {
  27. // Previous/next post navigation.
  28. the_post_navigation( array(
  29. 'next_text' => '<span class="meta-nav" aria-hidden="true">' . __( 'Next', 'twentysixteen' ) . '</span> ' .
  30. '<span class="screen-reader-text">' . __( 'Next post:', 'twentysixteen' ) . '</span> ' .
  31. '<span class="post-title">%title</span>',
  32. 'prev_text' => '<span class="meta-nav" aria-hidden="true">' . __( 'Previous', 'twentysixteen' ) . '</span> ' .
  33. '<span class="screen-reader-text">' . __( 'Previous post:', 'twentysixteen' ) . '</span> ' .
  34. '<span class="post-title">%title</span>',
  35. ) );
  36. }
  37. // End of the loop.
  38. endwhile;
  39. ?>
  40. </main><!-- .site-main -->
  41. <?php get_sidebar( 'content-bottom' ); ?>
  42. </div><!-- .content-area -->
  43. <?php get_sidebar(); ?>
  44. <?php get_footer(); ?>