Title: Sort Posts
Last modified: August 20, 2016

---

# Sort Posts

 *  Resolved [Joel Eade](https://wordpress.org/support/users/joeleade/)
 * (@joeleade)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/sort-posts-2/)
 * Hi All,
 * I had an issue sorting posts using QMT with checkboxes, and filtering by “Tags”.
 * I first tried adding
    `query_posts( $query_string . '&orderby=title' . '&order
   =ASC' );` before `if ( have_posts() ) : while ( have_posts() ) : the_post(); ?
   >` in my theme, which worked OK until I tried filtering using “Tags.”
 * I found this post [http://bit.ly/116bwHO](http://bit.ly/116bwHO), from which 
   I grabbed the below code:
 *     ```
       // Runs before the posts are fetched
       	add_filter( 'pre_get_posts' , 'my_change_order' );
       	// Function accepting current query
       	function my_change_order( $query ) {
       	// Check if the query is for an archive
       	if($query->is_archive)
       		// Query was for archive, then set order
       		$query->set( 'orderby' , 'title' );
       		$query->set( 'order' , 'asc' );
       	// Return the query (else there's no more query, oops!)
       	return $query;
       }
       ```
   
 * Works a treat!
 * [http://wordpress.org/extend/plugins/query-multiple-taxonomies/](http://wordpress.org/extend/plugins/query-multiple-taxonomies/)

The topic ‘Sort Posts’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/query-multiple-taxonomies.svg)
 * [Query Multiple Taxonomies](https://wordpress.org/plugins/query-multiple-taxonomies/)
 * [Support Threads](https://wordpress.org/support/plugin/query-multiple-taxonomies/)
 * [Active Topics](https://wordpress.org/support/plugin/query-multiple-taxonomies/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/query-multiple-taxonomies/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/query-multiple-taxonomies/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Joel Eade](https://wordpress.org/support/users/joeleade/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/sort-posts-2/)
 * Status: resolved