Changeset 25814
- Timestamp:
- 10/16/2013 06:28:11 PM (11 years ago)
- Location:
- trunk/src/wp-content/themes/twentyfourteen
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyfourteen/functions.php
r25808 r25814 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 * -
trunk/src/wp-content/themes/twentyfourteen/inc/featured-content.php
r25813 r25814 31 31 */ 32 32 public static function setup() { 33 add_action( 'init', array( __CLASS__ __, 'init' ), 30 );33 add_action( 'init', array( __CLASS__, 'init' ), 30 ); 34 34 } 35 35
Note: See TracChangeset
for help on using the changeset viewer.