获取所选自定义分类的名称
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取所选自定义分类的名称相关的知识,希望对你有一定的参考价值。
Use this to get the name of the custom taxonomy. Note that this only returns the name of the first selected item, but since this returns an array, use a foreach loop to find all names.
// get name of manufacturer of this post // replace 'manufacturer' with the id name of your custom taxomony $manufacturer = wp_get_post_terms($post->ID, 'manufacturer'); $manufacturer_name = $manufacturer[0]->name; // use this to display the name echo $manufacturer_name;
以上是关于获取所选自定义分类的名称的主要内容,如果未能解决你的问题,请参考以下文章