Changeset 42343 for trunk/src/wp-content/themes/twentyeleven/showcase.php
- Timestamp:
- 11/30/2017 11:09:33 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyeleven/showcase.php
r31265 r42343 24 24 <div id="content" role="main"> 25 25 26 <?php while ( have_posts() ) : the_post(); ?> 26 <?php 27 while ( have_posts() ) : 28 the_post(); 29 ?> 27 30 28 31 <?php … … 31 34 * If we have content for this page, let's display it. 32 35 */ 33 if ( '' != get_the_content() ) 34 get_template_part( 'content', 'intro' ); 36 if ( '' != get_the_content() ) { 37 get_template_part( 'content', 'intro' ); 38 } 35 39 ?> 36 40 … … 47 51 48 52 // Proceed only if sticky posts exist. 49 53 if ( ! empty( $sticky ) ) : 50 54 51 55 $featured_args = array( 52 'post__in' => $sticky,53 'post_status' => 'publish',56 'post__in' => $sticky, 57 'post_status' => 'publish', 54 58 'posts_per_page' => 10, 55 'no_found_rows' => true,59 'no_found_rows' => true, 56 60 ); 57 61 … … 62 66 if ( $featured->have_posts() ) : 63 67 64 /* 65 * We will need to count featured posts starting from zero 66 * to create the slider navigation. 67 */ 68 $counter_slider = 0; 69 70 // Compatibility with versions of WordPress prior to 3.4. 71 if ( function_exists( 'get_custom_header' ) ) 72 $header_image_width = get_theme_support( 'custom-header', 'width' ); 73 else 74 $header_image_width = HEADER_IMAGE_WIDTH; 75 ?> 76 77 <div class="featured-posts"> 68 /* 69 * We will need to count featured posts starting from zero 70 * to create the slider navigation. 71 */ 72 $counter_slider = 0; 73 74 // Compatibility with versions of WordPress prior to 3.4. 75 if ( function_exists( 'get_custom_header' ) ) { 76 $header_image_width = get_theme_support( 'custom-header', 'width' ); 77 } else { 78 $header_image_width = HEADER_IMAGE_WIDTH; 79 } 80 ?> 81 82 <div class="featured-posts"> 78 83 <h1 class="showcase-heading"><?php _e( 'Featured Post', 'twentyeleven' ); ?></h1> 79 84 80 85 <?php 81 // Let's roll. 82 while ( $featured->have_posts() ) : $featured->the_post(); 86 // Let's roll. 87 while ( $featured->have_posts() ) : 88 $featured->the_post(); 83 89 84 90 // Increase the counter. … … 86 92 87 93 /* 88 89 90 94 * We're going to add a class to our featured post for featured images 95 * by default it'll have the feature-text class. 96 */ 91 97 $feature_class = 'feature-text'; 92 98 … … 108 114 <section class="featured-post <?php echo esc_attr( $feature_class ); ?>" id="featured-post-<?php echo esc_attr( $counter_slider ); ?>"> 109 115 110 <?php 111 /* 112 * If the thumbnail is as big as the header image 113 * make it a large featured post, otherwise render it small 114 */ 115 if ( has_post_thumbnail() ) { 116 if ( $image[1] >= $header_image_width ) 117 $thumbnail_size = 'large-feature'; 118 else 119 $thumbnail_size = 'small-feature'; 120 ?> 121 <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_post_thumbnail( $thumbnail_size ); ?></a> 122 <?php 123 } 116 <?php 117 /* 118 * If the thumbnail is as big as the header image 119 * make it a large featured post, otherwise render it small 120 */ 121 if ( has_post_thumbnail() ) { 122 if ( $image[1] >= $header_image_width ) { 123 $thumbnail_size = 'large-feature'; 124 } else { 125 $thumbnail_size = 'small-feature'; 126 } 127 ?> 128 <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_post_thumbnail( $thumbnail_size ); ?></a> 129 <?php 130 } 124 131 ?> 125 132 <?php get_template_part( 'content', 'featured' ); ?> 126 133 </section> 127 <?php endwhile; 128 129 <?php134 <?php endwhile; ?> 135 136 <?php 130 137 // Show slider only if we have more than one featured post. 131 138 if ( $featured->post_count > 1 ) : 132 ?>133 <nav class="feature-slider">139 ?> 140 <nav class="feature-slider"> 134 141 <ul> 135 142 <?php 136 143 137 // Reset the counter so that we end up with matching elements 138 $counter_slider = 0; 139 140 // Begin from zero 141 rewind_posts(); 142 143 // Let's roll again. 144 while ( $featured->have_posts() ) : $featured->the_post(); 145 $counter_slider++; 146 if ( 1 == $counter_slider ) 147 $class = ' class="active"'; 148 else 149 $class = ''; 150 ?> 151 <li><a href="#featured-post-<?php echo esc_attr( $counter_slider ); ?>" title="<?php echo esc_attr( sprintf( __( 'Featuring: %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ) ); ?>"<?php echo $class; ?>></a></li> 152 <?php endwhile; ?> 144 // Reset the counter so that we end up with matching elements 145 $counter_slider = 0; 146 147 // Begin from zero 148 rewind_posts(); 149 150 // Let's roll again. 151 while ( $featured->have_posts() ) : 152 $featured->the_post(); 153 $counter_slider++; 154 if ( 1 == $counter_slider ) { 155 $class = ' class="active"'; 156 } else { 157 $class = ''; 158 } 159 ?> 160 <li><a href="#featured-post-<?php echo esc_attr( $counter_slider ); ?>" title="<?php echo esc_attr( sprintf( __( 'Featuring: %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ) ); ?>"<?php echo $class; ?>></a></li> 161 <?php endwhile; ?> 153 162 </ul> 154 </nav>155 <?php endif; // End check for more than one sticky post. ?>156 </div><!-- .featured-posts -->157 <?php endif; // End check for published posts. ?>163 </nav> 164 <?php endif; // End check for more than one sticky post. ?> 165 </div><!-- .featured-posts --> 166 <?php endif; // End check for published posts. ?> 158 167 <?php endif; // End check for sticky posts. ?> 159 168 … … 165 174 // Display our recent posts, showing full content for the very latest, ignoring Aside posts. 166 175 $recent_args = array( 167 'order' => 'DESC',168 'post__not_in' => get_option( 'sticky_posts' ),169 'tax_query' => array(176 'order' => 'DESC', 177 'post__not_in' => get_option( 'sticky_posts' ), 178 'tax_query' => array( 170 179 array( 171 180 'taxonomy' => 'post_format', 172 'terms' => array( 'post-format-aside', 'post-format-link', 'post-format-quote', 'post-format-status' ),173 'field' => 'slug',181 'terms' => array( 'post-format-aside', 'post-format-link', 'post-format-quote', 'post-format-status' ), 182 'field' => 'slug', 174 183 'operator' => 'NOT IN', 175 184 ), … … 182 191 183 192 // The first Recent post is displayed normally 184 if ( $recent->have_posts() ) : $recent->the_post(); 193 if ( $recent->have_posts() ) : 194 $recent->the_post(); 185 195 186 196 // Set $more to 0 in order to only get the first part of the post. … … 195 205 196 206 // For all other recent posts, just display the title and comment status. 197 while ( $recent->have_posts() ) : $recent->the_post(); ?> 207 while ( $recent->have_posts() ) : 208 $recent->the_post(); 209 ?> 198 210 199 211 <li class="entry-title"> … … 208 220 209 221 // If we had some posts, close the <ol> 210 if ( $recent->post_count > 0 ) 222 if ( $recent->post_count > 0 ) { 211 223 echo '</ol>'; 224 } 212 225 ?> 213 226 </section><!-- .recent-posts --> … … 217 230 218 231 <?php 219 the_widget( 'Twenty_Eleven_Ephemera_Widget', '', array( 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) ); 232 the_widget( 233 'Twenty_Eleven_Ephemera_Widget', '', array( 234 'before_title' => '<h3 class="widget-title">', 235 'after_title' => '</h3>', 236 ) 237 ); 220 238 ?> 221 239
Note: See TracChangeset
for help on using the changeset viewer.