/* * Setup the Index page, main query adjustments * * If we're viewing the site index get the first 5 posts * from the Marquee category (home-slider), ordered * by our meta value and ignoring any sticky stuff. * */ function mnsu_index_query( $query ) { if( is_home() && $query->is_main_query() ) { if( isset( $query->query_vars['post_type'] ) && 'tribe_events' == $query->query_vars['post_type'] ) { /** * Don't do anything. We have to add this additonal check to avoid applying the query * modification to The Events Calendar listing pages as they set is_home() to true. */ } else { // Set paging to 5 $query->set( 'posts_per_page', '5' ); $query->set( 'ignore_sticky_posts', 1 ); // Get posts from the Marquee category $tax_query = array ( array( 'taxonomy' => 'placements', 'terms' => array( 'home-slider' ), 'field' => 'slug', ) ); $query->set( 'tax_query', $tax_query ); $query->set( 'meta_key', 'mnsu_placement_home-slider' ); $query->set( 'orderby', 'meta_value_num' ); $query->set( 'order', 'ASC' ); } } } add_action( 'pre_get_posts', 'mnsu_index_query' );