delarge
7/7/2015 - 2:57 PM

Alter main query on archives

Alter main query on archives

//// ---- alter Video archive query
function alter_video_archive_query( $query ) {
if( ! is_admin() && $query->is_main_query() && is_post_type_archive('video')) {
//$query->set( 'orderby', 'title' );

$query->set('posts_per_page', 9);
$query->set( 'orderby', 'meta_value_num' );
$query->set( 'meta_key', 'video_release_date' );
$query->set( 'order', 'DESC' );

}
}
add_action( 'pre_get_posts', 'alter_video_archive_query' );