Ticket #25613: 25613.diff
| File 25613.diff, 5.0 KB (added by , 13 years ago) |
|---|
-
wp-content/themes/twentyfourteen/content-recent-formatted-post.php
1 <?php2 /**3 * The template to display recent Featured Posts4 *5 * @package WordPress6 * @subpackage Twenty_Fourteen7 * @since Twenty Fourteen 1.08 */9 if ( isset( $GLOBALS['content_width'] ) )10 $GLOBALS['content_width'] = 306;11 12 $images = get_posts( array(13 'post_parent' => get_post()->post_parent,14 'fields' => 'ids',15 'numberposts' => -1,16 'post_status' => 'inherit',17 'post_type' => 'attachment',18 'post_mime_type' => 'image',19 'order' => 'ASC',20 'orderby' => 'menu_order ID'21 ) );22 $total_images = count( $images );23 ?>24 25 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>26 <div class="entry-content">27 <?php28 if ( has_post_format( 'gallery' ) ) :29 if ( has_post_thumbnail() ) :30 $featured_image = get_the_post_thumbnail( get_the_ID(), 'featured-thumbnail-formatted' );31 elseif ( $total_images > 0 ) :32 $image = array_shift( $images );33 $featured_image = wp_get_attachment_image( $image, 'featured-thumbnail-formatted' );34 ?>35 <a href="<?php the_permalink(); ?>"><?php echo $featured_image; ?></a>36 <p class="wp-caption-text">37 <?php38 printf( _n( 'This gallery contains <a href="%1$s" rel="bookmark">%2$s photo</a>.', 'This gallery contains <a href="%1$s" rel="bookmark">%2$s photos</a>.', $total_images, 'twentyfourteen' ),39 esc_url( get_permalink() ),40 number_format_i18n( $total_images )41 );42 ?>43 </p>44 <?php45 else :46 the_excerpt();47 endif;48 else :49 the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyfourteen' ) );50 endif;51 ?>52 </div><!-- .entry-content -->53 54 <header class="entry-header">55 <div class="entry-meta">56 <?php57 if ( ! has_post_format( 'link' ) ) :58 the_title( '<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' );59 endif;60 61 twentyfourteen_posted_on();62 63 if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) :64 ?>65 <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyfourteen' ), __( '1 Comment', 'twentyfourteen' ), __( '% Comments', 'twentyfourteen' ) ); ?></span>66 <?php endif; ?>67 </div><!-- .entry-meta -->68 </header><!-- .entry-header -->69 </article><!-- #post-## --> -
wp-content/themes/twentyfourteen/functions.php
357 357 endif; 358 358 359 359 /** 360 * Get recent formatted posts that are not featured in Featured Content area.361 *362 * @since Twenty Fourteen 1.0363 *364 * @return object WP_Query365 */366 function twentyfourteen_get_recent( $post_format ) {367 $args = array(368 'order' => 'DESC',369 'ignore_sticky_posts' => 1,370 'posts_per_page' => 2,371 'tax_query' => array(372 array(373 'taxonomy' => 'post_format',374 'terms' => array( $post_format ),375 'field' => 'slug',376 'operator' => 'IN',377 ),378 ),379 'no_found_rows' => true,380 );381 382 $featured_posts = twentyfourteen_get_featured_posts();383 384 if ( is_array( $featured_posts ) && ! empty( $featured_posts ) )385 $args['post__not_in'] = wp_list_pluck( $featured_posts, 'ID' );386 387 return new WP_Query( $args );388 }389 390 /**391 * Filter the home page posts, and remove formatted posts visible in the sidebar from it392 *393 * @since Twenty Fourteen 1.0394 *395 * @return void396 */397 function twentyfourteen_pre_get_posts( $query ) {398 // Bail if not home, not a query, not main query.399 if ( ! $query->is_main_query() || is_admin() )400 return;401 402 // Only on the home page403 if ( $query->is_home() ) {404 $exclude_ids = array();405 406 $videos = twentyfourteen_get_recent( 'post-format-video' );407 $images = twentyfourteen_get_recent( 'post-format-image' );408 $galleries = twentyfourteen_get_recent( 'post-format-gallery' );409 $asides = twentyfourteen_get_recent( 'post-format-aside' );410 $links = twentyfourteen_get_recent( 'post-format-link' );411 $quotes = twentyfourteen_get_recent( 'post-format-quote' );412 413 foreach ( $videos->posts as $post )414 $exclude_ids[] = $post->ID;415 416 foreach ( $images->posts as $post )417 $exclude_ids[] = $post->ID;418 419 foreach ( $galleries->posts as $post )420 $exclude_ids[] = $post->ID;421 422 foreach ( $asides->posts as $post )423 $exclude_ids[] = $post->ID;424 425 foreach ( $links->posts as $post )426 $exclude_ids[] = $post->ID;427 428 foreach ( $quotes->posts as $post )429 $exclude_ids[] = $post->ID;430 431 $query->set( 'post__not_in', $exclude_ids );432 }433 }434 add_action( 'pre_get_posts', 'twentyfourteen_pre_get_posts' );435 436 /**437 360 * Extend the default WordPress body classes. 438 361 * 439 362 * Adds body classes to denote:
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)