在内容上显示自定义帖子类型及其自定义类别

时间:2018-07-14 14:03:05

标签: php wordpress

我想显示医生的自定义帖子类型及其自定义类别,例如儿科医生,并使用内置功能,例如该帖子的内容和类别。我面临的问题是我无法显示自定义帖子类型的自定义类别。我该如何实现?

自定义类别

..

内置功能以显示类别

输出

1 个答案:

答案 0 :(得分:0)

尝试一下

<?php $terms = get_the_terms($post->ID, 'yourtaxonomyhere');
foreach ($terms as $term) {
    $term_link = get_term_link($term, 'yourtaxonomyhere');
    if (is_wp_error($term_link))
        continue;
    echo '<a href="' . $term_link . '">' . $term->name . '</a>';
}
?>

另请参阅:https://developer.wordpress.org/reference/functions/get_the_terms/

相关问题