Skip to content

Instantly share code, notes, and snippets.

@pdewouters
Created June 26, 2012 13:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdewouters/2995754 to your computer and use it in GitHub Desktop.
Save pdewouters/2995754 to your computer and use it in GitHub Desktop.
change post order on post type archive / taxonomy archive
add_action( 'pre_get_posts', 'child_sort_post_order' );
function child_sort_post_order( $query ) {
if ( is_post_type_archive('my_post_type') || is_tax() ){
$query->query_vars['orderby'] = 'title';
$query->query_vars['order'] = 'asc';
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment