content-front.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * Template part for displaying pages on front page.
  4. *
  5. * @package Pique
  6. */
  7. ?>
  8. <article id="post-<?php the_ID(); ?>" <?php post_class( 'pique-panel pique-panel'. esc_attr( $pique_panel ) ); ?> data-panel-title="Panel <?php echo esc_attr( $pique_panel ); ?>" >
  9. <?php if ( has_post_thumbnail() ) :
  10. $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'pique-hero' ); ?>
  11. <div class="pique-panel-background" style="background-image:url(<?php echo esc_url( $thumbnail[0] ); ?>)"></div>
  12. <?php endif; ?>
  13. <div class="pique-panel-content">
  14. <header class="entry-header">
  15. <?php the_title( '<h2 class="entry-title">', '</h2>' ); ?>
  16. <?php if ( 'post' === get_post_type() ) : ?>
  17. <div class="entry-meta">
  18. <?php pique_posted_on(); ?>
  19. </div><!-- .entry-meta -->
  20. <?php endif; ?>
  21. </header><!-- .entry-header -->
  22. <footer class="entry-footer">
  23. <?php pique_edit_link( get_the_ID() ); ?>
  24. </footer><!-- .entry-footer -->
  25. <div class="entry-content">
  26. <?php
  27. /* translators: %s: Name of current post */
  28. the_content( sprintf(
  29. wp_kses( __( 'Continue reading %s <span class="meta-nav">&rarr;</span>', 'pique' ), array( 'span' => array( 'class' => array() ) ) ),
  30. the_title( '<span class="screen-reader-text">"', '"</span>', false )
  31. ) );
  32. ?>
  33. <?php
  34. // Show recent blog posts for blog panel (Note that get_option returns a string, so we're casting the result as an int)
  35. if ( get_the_ID() === (int) get_option( 'page_for_posts' ) ) : ?>
  36. <?php // Show three most recent posts
  37. $recent_posts = new WP_Query( array(
  38. 'posts_per_page' => 3,
  39. 'post_status' => 'publish',
  40. ) );
  41. ?>
  42. <?php if ( $recent_posts->have_posts() ) : ?>
  43. <div class="pique-recent-posts pique-grid-three">
  44. <?php
  45. // Since WordPress seem to be ignoring our posts_per_page above, let's just brute-force the limit
  46. // Note: it's also ignoring the user settings for posts_per_page and defaulting to 7. Maybe an issue
  47. // with Infinite Scroll? At any rate, I don't feel so bad about being brutish when it's also being a jerk.
  48. $count = 0;
  49. while ( $count < 3 AND $recent_posts->have_posts() ) : $recent_posts->the_post();
  50. get_template_part( 'components/content', 'excerpt' );
  51. $count++;
  52. endwhile;
  53. wp_reset_postdata();
  54. ?>
  55. </div><!-- .pique-recent-posts -->
  56. <?php endif; ?>
  57. <?php endif; ?>
  58. <?php // Show sub-pages of grid template page
  59. if ( 'page-templates/template-grid.php' === get_page_template_slug() ) :
  60. get_template_part( 'components/content', 'grid' );
  61. endif;
  62. // Show testimonials
  63. if ( 'page-templates/template-testimonials.php' === get_page_template_slug() ) :
  64. // Show two random testimonials
  65. $testimonials = pique_get_random_posts( 2, 'jetpack-testimonial' );
  66. ?>
  67. <?php if ( ! empty( $testimonials ) ) : ?>
  68. <div class="pique-testimonials pique-grid-two">
  69. <?php
  70. foreach ( $testimonials as $testimonial ) :
  71. $GLOBALS['post'] =& $testimonial;
  72. setup_postdata( $testimonial );
  73. get_template_part( 'components/content', 'testimonial' );
  74. endforeach;
  75. wp_reset_postdata();
  76. ?>
  77. </div><!-- .pique-testimonials -->
  78. <?php endif; ?>
  79. <?php endif; ?>
  80. <?php
  81. wp_link_pages( array(
  82. 'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'pique' ),
  83. 'after' => '</div>',
  84. ) );
  85. ?>
  86. </div><!-- .entry-content -->
  87. </div><!-- .pique-panel-content -->
  88. </article><!-- #post-## -->