WordPress.org

Ready to get started?Download WordPress

Forums

Query Multiple Taxonomies
[resolved] Sort Posts (1 post)

  1. joeleade
    Member
    Posted 1 year ago #

    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, 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/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic