Skip to content

Instantly share code, notes, and snippets.

@yousufansa
Created February 12, 2019 09:49
Show Gist options
  • Save yousufansa/68c521c6e1257cc7185e9fa1c7ff658a to your computer and use it in GitHub Desktop.
Save yousufansa/68c521c6e1257cc7185e9fa1c7ff658a to your computer and use it in GitHub Desktop.
Bethlehem - Change Team Members Order
if( ! function_exists( 'bethlehem_child_pre_get_posts' ) ) {
function bethlehem_child_pre_get_posts( $query ) {
if ( $query->is_post_type_archive( 'team-member' ) || $query->is_tax( get_object_taxonomies( 'team-member' ) ) ) {
if( ! isset( $query->query_vars['orderby'] ) ) {
$query->set( 'orderby', apply_filters( 'team_members_orderby', 'date' ) );
}
if( ! isset( $query->query_vars['order'] ) ) {
$query->set( 'order', apply_filters( 'team_members_order', 'DESC' ) );
}
}
return $query;
}
}
add_filter( 'pre_get_posts', 'bethlehem_child_pre_get_posts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment