Hello Leo,
You are most welcome, I hope the tips that we share here will prove to be helpful to you and possibly other users of the plugin! Your last question seems very interesting, even though strangely enough I don’t remember anybody ever asking about this.
Sorting by counts is not included as a built-in option, but since there was bound to exist a JS solution, I have test-driven the script below on one of our test sites, and it seems to do the trick:
jQuery( document ).ready( function( $ ){
'use strict';
if( 'undefined' !== typeof( a_w_f ) ) {
a_w_f.tags_filter_containers = [];
// Set the needed filters here:
$( '.awf-filters-container.awf-filters-product-tags > ul' ).each( function( i, el ) {
a_w_f.tags_filter_containers[i] = $( el );
});
if( 0 < a_w_f.tags_filter_containers.length ) {
a_w_f.sort_tags_by_counts = function() {
$.each( a_w_f.tags_filter_containers, function( i, $parent ) {
var $fcs = $parent.children( '.awf-filter-container' );
$fcs.sort( function( a, b ) {
return parseInt( $( a ).find( '.awf-filter-count' ).html() ) - parseInt( $( b ).find( '.awf-filter-count' ).html() );
});
$.each( $fcs, function() { $parent.prepend( $( this ) ); });
} );
};
$( document ).on( 'awf_after_counts_update', function() {
a_w_f.sort_tags_by_counts();
} );
a_w_f.sort_tags_by_counts();
}
}
});
If you like, try it from the annasta Filters > Plugin settings > Custom JavaScript box to see if it works for your tags filter. If you have changed the tags parameter labels, you can adjust the container selectors under the corresponding comment.
Disclaimer: though this seems to work on the basic Tags filter, the current script shouldn’t be used on very long lists and will not work on hierarchical taxonomies. It may also go into conflict with some complex JS options offered by the plugin, so please test thoroughly!