Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 Wordpress 中显示自定义分类的单个术语?
我有一个自定义分类法,它总是只有一个术语,我想在我的主页上以自定义循环显示它。我已经尝试了所有可能的方法,其中一种(布拉格,不记得是哪一种)我设法显示了该术语,但作为一个链接,我不想要。我需要它作为常规文本,因为我想在我自己的 href 中显示它,它将链接到我想要的地方。
有什么想法吗?非常感谢所有和任何帮助。这个问题正在减慢我开发自定义主题的速度。:(
get_term($term_ID, $taxonomy)使用或获取单个术语对象get_term_by('slug', $term_slug, $taxonomy)。
get_term($term_ID, $taxonomy)
get_term_by('slug', $term_slug, $taxonomy)
除其他属性外,术语对象将具有;
$term->name; // the name of the term! $term->slug; $term->term_id; $term->count; // number of objects using the term