Ticket #17198: 17198.showcase.2.diff
| File 17198.showcase.2.diff, 3.5 KB (added by , 15 years ago) |
|---|
-
wp-content/themes/twentyeleven/showcase.php
23 23 <?php 24 24 // See if we have any sticky posts and use the latest to create a featured post 25 25 $sticky = get_option( 'sticky_posts' ); 26 $featured_args = array( 27 'posts_per_page' => 1, 28 'post__in' => $sticky, 29 ); 30 31 $featured = new WP_Query(); 32 $featured->query( $featured_args ); 33 26 34 27 // Let's roll. 35 28 if ( $sticky ) : 36 37 $featured->the_post();38 39 // We're going to add a class to our featured post for featured images40 // by default it'll have no class though41 $feature_class = '';42 29 43 if ( has_post_thumbnail() ) { 44 // … but if it has a featured image let's add some class 45 $feature_class = 'feature-image small'; 30 $featured_args = array( 31 'posts_per_page' => 1, 32 'post__in' => $sticky, 33 'ignore_sticky_posts' => true, 34 ); 46 35 47 // Hang on. Let's check this here image out.48 $ image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_WIDTH ));36 $featured = new WP_Query(); 37 $featured->query( $featured_args ); 49 38 50 // Is it bigger than or equal to our header? 51 if ( $image[1] >= HEADER_IMAGE_WIDTH ) { 52 // Let's add a BIGGER class. It's EXTRA classy now. 53 $feature_class = 'feature-image large'; 54 } 55 } 56 ?> 57 58 <?php if ( has_post_thumbnail() ) : ?> 59 <section class="featured-post <?php echo $feature_class; ?>"> 60 <?php else : ?> 61 <section class="featured-post"> 62 <?php endif; ?> 39 while ( $featured->have_posts() ) : $featured->the_post(); 40 41 $feature_class = 'featured-post'; 42 43 // We're going to add a class to our featured post for featured images 44 if ( has_post_thumbnail() ) { 45 // Hang on. Let's check this here image out. 46 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_WIDTH ) ); 47 48 // Is it bigger than or equal to our header? 49 if ( $image[1] >= HEADER_IMAGE_WIDTH ) { 50 // Let's add a BIGGER class. It's EXTRA classy now. 51 $feature_class .= ' feature-image large'; 52 } else { 53 $feature_class .= ' feature-image small'; 54 } 55 } 56 ?> 57 58 <section class="<?php echo $feature_class; ?>"> 63 59 <h1 class="showcase-heading"><?php _e( 'Featured Post', 'twentyeleven' ); ?></h1> 64 60 <?php 65 61 // Dynamic thumbnails! … … 73 69 ?> 74 70 <?php get_template_part( 'content', 'featured' ); ?> 75 71 </section> 76 <?php endif; ?> 72 <?php endwhile; 73 endif; 74 ?> 77 75 78 76 <section class="recent-posts"> 79 77 <h1 class="showcase-heading"><?php _e( 'Recent Posts', 'twentyeleven' ); ?></h1> … … 95 93 ); 96 94 $recent = new WP_Query(); 97 95 $recent->query( $recent_args ); 98 $counter = 0;99 96 100 97 while ( $recent->have_posts() ) : $recent->the_post(); 101 98 // set $more to 0 in order to only get the first part of the post 102 99 global $more; 103 100 $more = 0; 104 $counter++;105 101 106 if ( 1 == $counter) :102 if ( 0 == $recent->current_post ) : 107 103 get_template_part( 'content', get_post_format() ); 108 104 echo '<ol class="other-recent-posts">'; 109 105