【问题标题】:How I can get custom post type taxonomy description? [closed]如何获取自定义帖子类型分类描述? [关闭]
【发布时间】:2017-02-16 04:11:05
【问题描述】:

如何获取自定义帖子类型分类描述?我的帖子类型是“发布” 并且分类是 'release_category' ,我应该使用什么代码?

【问题讨论】:

  • 先尝试自己,如果没有成功,请询问您的代码。

标签: php wordpress


【解决方案1】:

如果您已有 term_id

term_description($term_id, $taxonomy) : https://codex.wordpress.org/Function_Reference/term_description

term_description($term_id, 'release_category');

如果你只知道帖子ID

首先,您必须使用 wp_get_post_terms( $post_id, $taxonomy, $args ) 获取帖子分类:https://codex.wordpress.org/Function_Reference/wp_get_post_terms

$taxonomies = wp_get_post_terms(get_the_ID(), 'release_category', array('fields' => 'all'));
foreach($taxonomies as $taxonomy) {
    echo $taxonomy->description;
}

【讨论】:

    猜你喜欢
    • 2022-01-19
    • 1970-01-01
    • 2013-06-21
    • 2014-04-29
    • 2011-06-26
    • 2016-10-28
    • 2019-11-04
    • 2023-04-03
    相关资源
    最近更新 更多