• gadrent

    (@gadrent)


    Hi,

    A question about ascending and descending.
    There is no difference in using order_dir=“,asc” or order_dir=“,desc”.

    See code below:

    [searchandfilter submit_label=zoeken taxonomies=”boerderijnummer” order_dir=”,desc” order_by=“id”]

    [searchandfilter submit_label=zoeken taxonomies=”boerderijnummer” order_dir=”,asc” order_by=“id”]

    I want to change it the order in low figures on top, high figures last.

    Field: “Alle boerderijnummer”.

    Preferred: First number 1 and last 225.

    Thanks.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • gmattje

    (@gmattje)

    Hi,

    I was having the same problem, and after searching a lot and not finding the solution I decided to solve the problem without entering the PHP code of the plugin, to be free for a future update.

    What I did was a js code (depends on jquery) that solves the case of alphabetical ordering.

    In my case I order categories and tags and this single code solves both at the same time.

    I hope it helps.

    jQuery(document).ready(function() {
    jQuery(‘form.searchandfilter select’).each(function(){
    var options = jQuery(this).find(‘option’);
    var arr = options.map(function(_, o) {
    return {
    t: jQuery(o).text(),
    v: o.value,
    s: jQuery(o).attr(‘selected’)
    };
    }).get();
    arr.sort(function(o1, o2) {
    if(o1.v > 0) {
    return o1.t > o2.t ? 1 : o1.t < o2.t ? -1 : 0;
    }
    });
    options.each(function(i, o) {
    o.value = arr[i].v;
    jQuery(o).text(arr[i].t);
    jQuery(o).attr(‘selected’, arr[i].s);
    });
    });
    });

    • This reply was modified 8 years ago by gmattje.
    Thread Starter gadrent

    (@gadrent)

    Hi Guilherme,

    Sorry for the late reaction.

    Can you tell me where you placed the code?

    Thanks.

    Hello,
    I put the code directly into the footer.php inside <script> tags, but you could create an external js file and declare it in your functions.php to keep the organization.

    both ways should work with the plugin.

    Hug!

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

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