PHP Wordpress:逗号分隔的分类术语列表

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP Wordpress:逗号分隔的分类术语列表相关的知识,希望对你有一定的参考价值。

<?php
// Get a list of terms for this post's custom taxonomy.
$project_cats = get_the_terms($post->ID, 'TAXONOMY_NAME');
// Renumber array.
$project_cats = array_values($project_cats);
for($cat_count=0; $cat_count<count($project_cats); $cat_count++) {
    // Each array item is an object. Display its 'name' value.
    echo $project_cats[$cat_count]->name;
    // If there is more than one term, comma separate them.
    if ($cat_count<count($project_cats)-1){
        echo ', ';
    }
}
?>

以上是关于PHP Wordpress:逗号分隔的分类术语列表的主要内容,如果未能解决你的问题,请参考以下文章