在 Wordpress 中显示自定义分类的单个术语

发布于 2024-09-04 08:50:03 字数 234 浏览 7 评论 0原文

如何在 Wordpress 中显示自定义分类法的单个术语?

我有一个自定义分类法,其中始终只有一个术语,并且我想在主页上的自定义循环中显示它。我已经尝试了所有可能的方法,其中一种(废话,不记得是哪一种)我设法显示该术语,但作为链接,这是我不想要的。我需要它作为常规文本,因为我想在我自己的 href 中显示它,它将链接到我想要的位置。

有人有什么想法吗?非常感谢所有和任何帮助。这个问题减慢了我自定义主题的开发速度。 :(

How am I able to show a single term of a custom taxonomy in Wordpress?

I have a custom taxonomy, which will always have only one term in it, and I want to display it in a custom loop on my home page. I have tried all possible ways, with one (blargh, can't remember which one) I managed to display the term but as a link, which I don't want. I need it as regular text, since I want to display it in my own href, which will link to the place where I want to.

Any ideas anyone? All and any help very much appreciated. This issue is slowing down my development of a custom theme. :(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花辞树 2024-09-11 08:50:03

使用 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

Get the single term object using get_term($term_ID, $taxonomy), or alternatively get_term_by('slug', $term_slug, $taxonomy).

The term object will have, among other properties;

$term->name; // the name of the term!
$term->slug;
$term->term_id;
$term->count; // number of objects using the term
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文