• Resolved graphik

    (@graphik)


    I’m trying to have a drop down option in my filter bar to sort the results either by ASC or DESC.

    I have this code which gives me the options in the form of radio buttons but I’m unable to change this code to give me the equivalent in drop down form:

    add_filter('uwpqsf_form_bottom','injecting_buttons','',4);
    function injecting_buttons(){
    echo '<div id="cmf_sort_by">';
    echo '<input  type="hidden" name="date" value="'.$taxname.'">';
    echo '<input  type="hidden" name="date" value="'.$opt.'">';
    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>';
    echo '</div>';
    }
    
    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;
    }

    https://www.ads-software.com/plugins/ultimate-wp-query-search-filter/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author TC.K

    (@wp_dummy)

    The dropdown html is using <select></select> , so just replaced the radio input.

    eg.

    <select name="date">
    <option value="DESC">Sort By Newest</option>
    <option value="ASC">Sort By Oldest</option>
    </select>

    How to change position of this dropdown? I want it below my 2nd taxonomy field

    Plugin Author TC.K

    (@wp_dummy)

    No you can’t, it is either top, center or bottom of the search input fields.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sort filter results by date in dropdown’ is closed to new replies.