【问题标题】:How to get custom taxonomy slug(s)?如何获得自定义分类蛞蝓?
【发布时间】:2015-01-07 09:13:26
【问题描述】:

我正在为 WordPress 主题目录制作一个 WordPress 作品集主题。 我为我的自定义帖子类型portfolio 创建了一个分类(名称:speciality)。我可以得到清单:

echo get_the_term_list( $post->ID, 'speciality', 'Portfolio Specialities: ', ', ' );

但我需要一份关于这个“专业”分类的蛞蝓列表。甚至我也想要单一的蛞蝓名称“专业”分类法。

如何获取此自定义分类的 slug/slug-name 列表?

【问题讨论】:

  • 天哪,没有人找到这个问题?

标签: wordpress wordpress-theming


【解决方案1】:

以下代码应该会有所帮助

$terms = get_the_terms( $post->ID, 'speciality' ); 

foreach( $terms as $term ) {
    echo $term->name . " : " . $term->slug; 
}

查看Codex了解更多信息

【讨论】:

    猜你喜欢
    • 2013-03-24
    • 1970-01-01
    • 1970-01-01
    • 2015-11-13
    • 2016-07-27
    • 2022-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多