0

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.

4

1 回答 1

0

the_terms() 正在使用 get_term_list 来检索代码的分类法(http://core.trac.wordpress.org/browser/tags/3.0.4/wp-includes/category-template.php#L932)。

您可以选择在此处使用过滤器,但它适用于为每个术语生成的 HTML(分类 1)。不是排序的最佳选择。

最好是使用函数 get_the_terms() ,对结果进行排序并自己构建输出列表!

于 2011-01-29T23:37:36.397 回答