singular.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * The template for displaying all pages, single posts and attachments
  4. *
  5. * This is a new template file that WordPress introduced in
  6. * version 4.3. Note that it uses conditional logic to display
  7. * different content based on the post type.
  8. *
  9. * @link https://codex.wordpress.org/Template_Hierarchy
  10. *
  11. * @package WordPress
  12. * @subpackage Twenty_Sixteen
  13. * @since Twenty Sixteen 1.0
  14. */
  15. get_header(); ?>
  16. <div id="primary" class="content-area">
  17. <main id="main" class="site-main" role="main">
  18. <?php
  19. // Start the loop.
  20. while ( have_posts() ) : the_post();
  21. // Include the page content template.
  22. if ( is_singular( 'page' ) ) {
  23. get_template_part( 'template-parts/content', 'page' );
  24. } else {
  25. get_template_part( 'template-parts/content', 'single' );
  26. }
  27. // If comments are open or we have at least one comment, load up the comment template.
  28. if ( comments_open() || get_comments_number() ) {
  29. comments_template();
  30. }
  31. if ( is_singular( 'attachment' ) ) {
  32. // Parent post navigation
  33. the_post_navigation( array(
  34. 'prev_text' => _x( '<span class="meta-nav">Published in</span><span class="post-title">%title</span>', 'Parent post link', 'twentysixteen' ),
  35. ) );
  36. } elseif ( is_singular( 'post' ) ) {
  37. // Previous/next post navigation.
  38. the_post_navigation( array(
  39. 'next_text' => '<span class="meta-nav" aria-hidden="true">' . __( 'Next', 'twentysixteen' ) . '</span> ' .
  40. '<span class="screen-reader-text">' . __( 'Next post:', 'twentysixteen' ) . '</span> ' .
  41. '<span class="post-title">%title</span>',
  42. 'prev_text' => '<span class="meta-nav" aria-hidden="true">' . __( 'Previous', 'twentysixteen' ) . '</span> ' .
  43. '<span class="screen-reader-text">' . __( 'Previous post:', 'twentysixteen' ) . '</span> ' .
  44. '<span class="post-title">%title</span>',
  45. ) );
  46. }
  47. // End of the loop.
  48. endwhile;
  49. ?>
  50. </main><!-- .site-main -->
  51. <?php get_sidebar( 'content-bottom' ); ?>
  52. </div><!-- .content-area -->
  53. <?php get_sidebar(); ?>
  54. <?php get_footer(); ?>