The easiest way to do this is to use a hook (the pre_get_posts
hook) to change the order. But you should check that the query is one for which you do want to alter the order! (is_archive()
or is_post_type_archive()
should be sufficient.)
For instance, put the following in your theme’s functions.php file.
1 2 3 4 5 6 7 8 9 10 11 | add_action( 'pre_get_posts', 'my_change_sort_order'); function my_change_sort_order($query){ if(is_archive()): //If you wanted it for the archive of a custom post type use: is_post_type_archive( $post_type ) //Set the order ASC or DESC $query->set( 'order', 'ASC' ); //Set the orderby $query->set( 'orderby', 'title' ); endif; }; |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.