Skip to content

Instantly share code, notes, and snippets.

@JiveDig
Last active December 17, 2015 08:08
Show Gist options
  • Save JiveDig/5577769 to your computer and use it in GitHub Desktop.
Save JiveDig/5577769 to your computer and use it in GitHub Desktop.
// Sort credits post type archive by credit year
add_action('pre_get_posts','child_alter_credits_archive_query');
function child_alter_credits_archive_query( $query ) {
if( $query->is_main_query() && is_post_type_archive('credits') ) {
$query->set( 'meta_key', 'credit_year' );
$query->set( 'orderby', 'meta_value_num' );
$query->set( 'order', 'DESC' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment