Title: Multiple Sort by Options
Last modified: August 21, 2016

---

# Multiple Sort by Options

 *  [Vegan Vader](https://wordpress.org/support/users/dootie-fresh/)
 * (@dootie-fresh)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/multiple-sort-by-options/)
 * Hello,
 * Is it possible to have multiple sorting options available on the search form 
   based on custom post meta?
 * I see you can set a single sort option, I’m looking to have multiple options 
   on the form so users can sort their results based on meta values for example 
   check boxes next to the search button;
    Price: low to high, Price: high to low,
   Year: low to high, Year: high to low?
 * Thanks
 * [http://wordpress.org/plugins/ultimate-wp-query-search-filter/](http://wordpress.org/plugins/ultimate-wp-query-search-filter/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [TC.K](https://wordpress.org/support/users/wp_dummy/)
 * (@wp_dummy)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/multiple-sort-by-options/#post-4481718)
 * Yes, it is possible with the some hooks. But it is rather complicated.
 * Basically, you can add the extra sorting by using `uwpqsf_form_bottom` filter,
   and using `uwpqsf_deftemp_query` filter (for default search template) or `uwpqsf_query_args`
   to inject it into the search query.
 *  [csumrell](https://wordpress.org/support/users/csumrell/)
 * (@csumrell)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/multiple-sort-by-options/#post-4481998)
 * How can I add the ASC and DSC order by date checkboxes to the Search Form on 
   the page. I have the checkboxes there on the form, but how do I inject that input
   into the ajax search query?
 *  Plugin Author [TC.K](https://wordpress.org/support/users/wp_dummy/)
 * (@wp_dummy)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/multiple-sort-by-options/#post-4481999)
 * You can inject it by using `uwpqsf_query_args`.
 * For eg.
 *     ```
       add_filter('uwpqsf_query_args','injecting_custom_arg','',4);
       function injecting_custom_arg($args, $id,$getdata){
         //$getdata is the data from the form input. Using it like GET url parameter
        $args['orderby'] = $getdata['orderby_name']; //if orderby_name is your input name.
        $args['order'] = $getdata['sort'];//likewise sort is the name of the order input.
        return $args;
       }
       ```
   
 *  [csumrell](https://wordpress.org/support/users/csumrell/)
 * (@csumrell)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/multiple-sort-by-options/#post-4482000)
 * Thank you for the help.
 * This is the code I ended up using to add two buttons: Sort By Newest and Sort
   By Oldest, that filter results by date to the search filter.
 * add_filter(‘uwpqsf_form_bottom’,’injecting_buttons’,”,4);
    function injecting_buttons(){
   echo ‘<label><input ‘.$desc.’ type=”radio” id=”taxhide” name=”date” value=”DESC”/
   >’.__(“Sort By Newest”,”UWPQSF”).'</label>’; echo ‘<label><input ‘.$asc.’ type
   =”radio” id=”taxhide” name=”date” value=”ASC”/>’.__(“Sort By Oldest”,”UWPQSF”).'
   </label>‘; }
 * add_filter(‘uwpqsf_query_args’,’injecting_custom_arg’,”,4);
    function injecting_custom_arg(
   $args, $id,$getdata){ $args[‘order’] = $getdata[‘date’];//likewise sort is the
   name of the order input.
 *  return $args;
    }
 *  [Umakant Sonwani](https://wordpress.org/support/users/omikant/)
 * (@omikant)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/multiple-sort-by-options/#post-4482024)
 * Hi Csumrell,
    How call this filter function in my custom page ,
 * ///////////////////////////////////////////////////////
 * add_filter(‘uwpqsf_form_bottom’,’injecting_buttons’,”,4);
    function injecting_buttons(){
   echo ‘<label><input ‘.$desc.’ type=”radio” id=”taxhide” name=”date” value=”DESC”/
   >’.__(“Sort By Newest”,”UWPQSF”).'</label>’; echo ‘<label><input ‘.$asc.’ type
   =”radio” id=”taxhide” name=”date” value=”ASC”/>’.__(“Sort By Oldest”,”UWPQSF”).'
   </label> ‘; }
 * add_filter(‘uwpqsf_query_args’,’injecting_custom_arg’,”,4);
    function injecting_custom_arg(
   $args, $id,$getdata){ $args[‘order’] = $getdata[‘date’];//likewise sort is the
   name of the order input.
 * return $args;
    }
 * //////////////////////////////////////////////////////////
    Thanks,

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Multiple Sort by Options’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/ultimate-wp-query-search-filter_fcfcfc.
   svg)
 * [Ultimate WP Query Search Filter](https://wordpress.org/plugins/ultimate-wp-query-search-filter/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ultimate-wp-query-search-filter/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ultimate-wp-query-search-filter/)
 * [Active Topics](https://wordpress.org/support/plugin/ultimate-wp-query-search-filter/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ultimate-wp-query-search-filter/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ultimate-wp-query-search-filter/reviews/)

 * 5 replies
 * 4 participants
 * Last reply from: [Umakant Sonwani](https://wordpress.org/support/users/omikant/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/multiple-sort-by-options/#post-4482024)
 * Status: not resolved