Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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!

    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 7 years, 12 months ago by gmattje.
Viewing 2 replies - 1 through 2 (of 2 total)