Double post.
Did you check this informations?
–> https://wordpress.org/support/topic/sorting-the-list/
As this names will not change: A fast and easy fix would be to copy the names and create a list yourself.
You can copy it from here : https://contactform7.com/listo/
-
This reply was modified 5 years, 11 months ago by
kraeMit.
-
This reply was modified 5 years, 11 months ago by
kraeMit.
I would prefer answer from the creator
I don’t want long list, the idea of the plugin is to avoid long list
Hello @mstudioil,
You can sort the countries alphabetically this way:
function wpcf7_listo_ordered( $data ) {
sort( $data );
return $data;
}
add_filter( 'wpcf7_form_tag_data_option', 'wpcf7_listo_ordered', 11, 1 );
Best regards,
Yordan.
Thanks, @yordansoares
I don’t understand why the list is not sorted from the begin
I’ve used this on my website, skips the first entry (contains “Select” text). Change the ID (i.e. ‘#country’) as needed.
// Country sorting function
if (jQuery('.wpcf7-form').length) {
var options = jQuery('option:gt(1)', '#country'),
arr = options.map(function(_, o) { return { t: jQuery(o).text(), v: o.value }; }).get();
arr.sort(function(o1, o2) { 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);
});
}
Ideally, this would be included in the plugin – visible name sorting is more logical than the ISO sorting.