سؤال

I'm using a custom taxonomy for my posts which I print like this:

the_terms(get_the_ID(), 'sizes', '<p>', ', ', '</p>');

This works fine but it prints the terms in the order they were added, is there a way to make it print alphabeticaly? the_terms function doesn't let me pass any order parameter so I guess I have to use a different one but I haven't found any yet.

Thanks in advance.

هل كانت مفيدة؟

المحلول

the_terms() is using get_term_list, to retrive the taxonomy ( http://core.trac.wordpress.org/browser/tags/3.0.4/wp-includes/category-template.php#L932 ) for the code.

You have the option to use a filter here, but it is applyed to the HTML generated for every single term (taxonomy1). Not the best option to sort.

Best is use the function get_the_terms() , sorting the results and constructing the output list by yourself!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top