[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-content/themes/twentyseventeen/template-parts/page/ -> content-front-page-panels.php (source)

   1  <?php
   2  /**
   3   * Template part for displaying pages on front page
   4   *
   5   * @package WordPress
   6   * @subpackage Twenty_Seventeen
   7   * @since Twenty Seventeen 1.0
   8   * @version 1.0
   9   */
  10  
  11  /**
  12   * @global int|string $twentyseventeencounter Front page section counter.
  13   */
  14  global $twentyseventeencounter;
  15  
  16  ?>
  17  
  18  <article id="panel<?php echo $twentyseventeencounter; ?>" <?php post_class( 'twentyseventeen-panel ' ); ?> >
  19  
  20      <?php
  21      if ( has_post_thumbnail() ) :
  22          $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'twentyseventeen-featured-image' );
  23  
  24          // Calculate aspect ratio: h / w * 100%.
  25          $ratio = $thumbnail[2] / $thumbnail[1] * 100;
  26          ?>
  27  
  28          <div class="panel-image" style="background-image: url(<?php echo esc_url( $thumbnail[0] ); ?>);">
  29              <div class="panel-image-prop" style="padding-top: <?php echo esc_attr( $ratio ); ?>%"></div>
  30          </div><!-- .panel-image -->
  31  
  32      <?php endif; ?>
  33  
  34      <div class="panel-content">
  35          <div class="wrap">
  36              <header class="entry-header">
  37                  <?php the_title( '<h2 class="entry-title">', '</h2>' ); ?>
  38  
  39                  <?php twentyseventeen_edit_link( get_the_ID() ); ?>
  40  
  41              </header><!-- .entry-header -->
  42  
  43              <div class="entry-content">
  44                  <?php
  45                      the_content(
  46                          sprintf(
  47                              /* translators: %s: Post title. Only visible to screen readers. */
  48                              __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
  49                              get_the_title()
  50                          )
  51                      );
  52                      ?>
  53              </div><!-- .entry-content -->
  54  
  55              <?php
  56              // Show recent blog posts if is blog posts page (Note that get_option returns a string, so we're casting the result as an int).
  57              if ( get_the_ID() === (int) get_option( 'page_for_posts' ) ) :
  58                  ?>
  59  
  60                  <?php
  61                  // Show three most recent posts.
  62                  $recent_posts = new WP_Query(
  63                      array(
  64                          'posts_per_page'      => 3,
  65                          'post_status'         => 'publish',
  66                          'ignore_sticky_posts' => true,
  67                          'no_found_rows'       => true,
  68                      )
  69                  );
  70                  ?>
  71  
  72                  <?php if ( $recent_posts->have_posts() ) : ?>
  73  
  74                      <div class="recent-posts">
  75  
  76                          <?php
  77                          while ( $recent_posts->have_posts() ) :
  78                              $recent_posts->the_post();
  79                              get_template_part( 'template-parts/post/content', 'excerpt' );
  80                          endwhile;
  81                          wp_reset_postdata();
  82                          ?>
  83                      </div><!-- .recent-posts -->
  84                  <?php endif; ?>
  85              <?php endif; ?>
  86  
  87          </div><!-- .wrap -->
  88      </div><!-- .panel-content -->
  89  
  90  </article><!-- #post-<?php the_ID(); ?> -->


Generated : Wed Jul 1 08:20:12 2026 Cross-referenced by PHPXref