【问题标题】:order post taxonomies alphabeticaly in wordpress?在wordpress中按字母顺序排序帖子分类法?
【发布时间】:2011-06-17 14:38:56
【问题描述】:

我正在为我的帖子使用自定义分类法,我这样打印:

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

这很好用,但它会按照添加的顺序打印条款,有没有办法让它按字母顺序打印? the_terms 函数不允许我传递任何订单参数,所以我想我必须使用不同的参数,但我还没有找到。

提前致谢。

【问题讨论】:

    标签: wordpress taxonomy term custom-tags


    【解决方案1】:

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

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

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

    【讨论】:

    • 现在我看到 the_term 默认按字母顺序排列,问题是我有例如 18 m、3 m、6 m,它首先显示 18,我猜是因为“1”这很奇怪..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-02
    • 2014-10-13
    • 1970-01-01
    • 2012-11-02
    • 1970-01-01
    • 1970-01-01
    • 2017-09-08
    相关资源
    最近更新 更多