[ 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  global $twentyseventeencounter;
  12  
  13  ?>
  14  
  15  <article id="panel<?php echo $twentyseventeencounter; ?>" <?php post_class( 'twentyseventeen-panel ' ); ?> >
  16  
  17      <?php
  18      if ( has_post_thumbnail() ) :
  19          $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'twentyseventeen-featured-image' );
  20  
  21          // Calculate aspect ratio: h / w * 100%.
  22          $ratio = $thumbnail[2] / $thumbnail[1] * 100;
  23          ?>
  24  
  25          <div class="panel-image" style="background-image: url(<?php echo esc_url( $thumbnail[0] ); ?>);">
  26              <div class="panel-image-prop" style="padding-top: <?php echo esc_attr( $ratio ); ?>%"></div>
  27          </div><!-- .panel-image -->
  28  
  29      <?php endif; ?>
  30  
  31      <div class="panel-content">
  32          <div class="wrap">
  33              <header class="entry-header">
  34                  <?php the_title( '<h2 class="entry-title">', '</h2>' ); ?>
  35  
  36                  <?php twentyseventeen_edit_link( get_the_ID() ); ?>
  37  
  38              </header><!-- .entry-header -->
  39  
  40              <div class="entry-content">
  41                  <?php
  42                      the_content(
  43                          sprintf(
  44                              /* translators: %s: Post title. Only visible to screen readers. */
  45                              __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
  46                              get_the_title()
  47                          )
  48                      );
  49                      ?>
  50              </div><!-- .entry-content -->
  51  
  52              <?php
  53              // 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).
  54              if ( get_the_ID() === (int) get_option( 'page_for_posts' ) ) :
  55                  ?>
  56  
  57                  <?php
  58                  // Show three most recent posts.
  59                  $recent_posts = new WP_Query(
  60                      array(
  61                          'posts_per_page'      => 3,
  62                          'post_status'         => 'publish',
  63                          'ignore_sticky_posts' => true,
  64                          'no_found_rows'       => true,
  65                      )
  66                  );
  67                  ?>
  68  
  69                  <?php if ( $recent_posts->have_posts() ) : ?>
  70  
  71                      <div class="recent-posts">
  72  
  73                          <?php
  74                          while ( $recent_posts->have_posts() ) :
  75                              $recent_posts->the_post();
  76                              get_template_part( 'template-parts/post/content', 'excerpt' );
  77                          endwhile;
  78                          wp_reset_postdata();
  79                          ?>
  80                      </div><!-- .recent-posts -->
  81                  <?php endif; ?>
  82              <?php endif; ?>
  83  
  84          </div><!-- .wrap -->
  85      </div><!-- .panel-content -->
  86  
  87  </article><!-- #post-<?php the_ID(); ?> -->


Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref