How to Sort Category Translated in WPML to Alphabetical Order

1. Firstly, use the JSON option at admin settings page, more details available in this article here http://superstorefinder.net/support/knowledgebase/json-data-source-for-super-store-finder-for-wordpress/

2. Next, you can edit js/mega-superstorefinder.js

Search for:

function continueInit() {

 /*---- Setup legend ----*/

 legend = {};

 var radiosStrArray = [];
 if(typeof ssf_data_source==='undefined' || ssf_data_source=='false'){
 jQuery(xml.data).find('label').each(function() {

 var tag = jQuery(this).find('tag').text().trim();

 var copy = jQuery(this).find('copy').text().trim();
 
 legend[tag] = copy;

 radiosStrArray.push([

 '<label class="label--vertical-align ssflabel">',

 '<div class="label__input-icon">',

 '<i class="icon icon--input icon--radio-btn"></i>',

 '</div>',

 '<div class="label__contents">',

 '<input type="radio" name="storesProductsServices" value="', tag, '" /> ', copy,

 '</div>',

 '</label>'

 ].join(''));

 });
 }else{
 
 jQuery(xml.data.tags).each(function() {
 var tag = this.tag;
 var copy = this.copy;
 legend[tag] = copy;

 radiosStrArray.push([

 '<label class="label--vertical-align ssflabel">',

 '<div class="label__input-icon">',

 '<i class="icon icon--input icon--radio-btn"></i>',

 '</div>',

 '<div class="label__contents">',

 '<input type="radio" name="storesProductsServices" value="', tag, '" /> ', copy,

 '</div>',

 '</label>'

 ].join(''));

 });
 
 }
 
 jQuery('#productsServicesFilterOptions').append(radiosStrArray.join(''));
 if(ssf_default_category!='' && ssf_default_category!=undefined){
 jQuery(function() {
 setTimeout(function(){
 jQuery('input[value='+ssf_default_category+']').trigger('click');
 jQuery('#filter__services .filter__toggler').trigger('click');
 },3000);
 });
 }
 
 $els.filters.init().productsServices.inputify();

 /*---- Setup store count ----*/
 
 if(typeof ssf_data_source==='undefined' || ssf_data_source=='false'){
 $els.totalStoreCount.text(jQuery(xml.data).find('item').length);
 }else{ 
 $els.totalStoreCount.text(jQuery(xml.data.item).length); 
 }

 startMap();

 }

 }

Change it to:

function continueInit() {

 /*---- Setup legend ----*/

 legend = {};

 var radiosStrArray = [];
 if(typeof ssf_data_source==='undefined' || ssf_data_source=='false'){
 jQuery(xml.data).find('label').each(function() {

 var tag = jQuery(this).find('tag').text().trim();

 var copy = jQuery(this).find('copy').text().trim();
 
 legend[tag] = copy;

 radiosStrArray.push([

 '<label class="label--vertical-align ssflabel">',

 '<div class="label__input-icon">',

 '<i class="icon icon--input icon--radio-btn"></i>',

 '</div>',

 '<div class="label__contents">',

 '<input type="radio" name="storesProductsServices" value="', tag, '" /> ', copy,

 '</div>',

 '</label>'

 ].join(''));

 });
 }else{
 
// sorting changes here
 xml.data.tags.sort(function(a, b){
 if(a.copy < b.copy) { return -1; } if(a.copy > b.copy) { return 1; }
 return 0;
 });
// sorting changes here 
 
 jQuery(xml.data.tags).each(function() {
 var tag = this.tag;
 var copy = this.copy;
 legend[tag] = copy;

 radiosStrArray.push([

 '<label class="label--vertical-align ssflabel">',

 '<div class="label__input-icon">',

 '<i class="icon icon--input icon--radio-btn"></i>',

 '</div>',

 '<div class="label__contents">',

 '<input type="radio" name="storesProductsServices" value="', tag, '" /> ', copy,

 '</div>',

 '</label>'

 ].join(''));

 });
 
 }
 
 jQuery('#productsServicesFilterOptions').append(radiosStrArray.join(''));
 if(ssf_default_category!='' && ssf_default_category!=undefined){
 jQuery(function() {
 setTimeout(function(){
 jQuery('input[value='+ssf_default_category+']').trigger('click');
 jQuery('#filter__services .filter__toggler').trigger('click');
 },3000);
 });
 }
 
 $els.filters.init().productsServices.inputify();

 /*---- Setup store count ----*/
 
 if(typeof ssf_data_source==='undefined' || ssf_data_source=='false'){
 $els.totalStoreCount.text(jQuery(xml.data).find('item').length);
 }else{ 
 $els.totalStoreCount.text(jQuery(xml.data.item).length); 
 }

 startMap();

 }

 }
1+

Users who have LIKED this post:

  • Sofia Moss