]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-content/themes/twentyseventeen/template-parts/page/content-front-page-panels.php
WordPress 4.7-scripts
[autoinstalls/wordpress.git] / wp-content / themes / twentyseventeen / template-parts / page / content-front-page-panels.php
1 <?php
2 /**
3  * Template part for displaying pages on front page
4  *
5  * @package WordPress
6  * @subpackage Twenty_Seventeen
7  * @since 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 if ( has_post_thumbnail() ) :
18                 $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'twentyseventeen-featured-image' );
19
20                 // Calculate aspect ratio: h / w * 100%.
21                 $ratio = $thumbnail[2] / $thumbnail[1] * 100;
22                 ?>
23
24                 <div class="panel-image" style="background-image: url(<?php echo esc_url( $thumbnail[0] ); ?>);">
25                         <div class="panel-image-prop" style="padding-top: <?php echo esc_attr( $ratio ); ?>%"></div>
26                 </div><!-- .panel-image -->
27
28         <?php endif; ?>
29
30         <div class="panel-content">
31                 <div class="wrap">
32                         <header class="entry-header">
33                                 <?php the_title( '<h2 class="entry-title">', '</h2>' ); ?>
34
35                                 <?php twentyseventeen_edit_link( get_the_ID() ); ?>
36
37                         </header><!-- .entry-header -->
38
39                         <div class="entry-content">
40                                 <?php
41                                         /* translators: %s: Name of current post */
42                                         the_content( sprintf(
43                                                 __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
44                                                 get_the_title()
45                                         ) );
46                                 ?>
47                         </div><!-- .entry-content -->
48
49                         <?php
50                         // 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).
51                         if ( get_the_ID() === (int) get_option( 'page_for_posts' )  ) : ?>
52
53                                 <?php // Show four most recent posts.
54                                 $recent_posts = new WP_Query( array(
55                                         'posts_per_page'      => 3,
56                                         'post_status'         => 'publish',
57                                         'ignore_sticky_posts' => true,
58                                         'no_found_rows'       => true,
59                                 ) );
60                                 ?>
61
62                                 <?php if ( $recent_posts->have_posts() ) : ?>
63
64                                         <div class="recent-posts">
65
66                                                 <?php
67                                                 while ( $recent_posts->have_posts() ) : $recent_posts->the_post();
68                                                         get_template_part( 'template-parts/post/content', 'excerpt' );
69                                                 endwhile;
70                                                 wp_reset_postdata();
71                                                 ?>
72                                         </div><!-- .recent-posts -->
73                                 <?php endif; ?>
74                         <?php endif; ?>
75
76                 </div><!-- .wrap -->
77         </div><!-- .panel-content -->
78
79 </article><!-- #post-## -->