在 Wordpress 中显示自定义分类的单个术语
如何在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
get_term($term_ID, $taxonomy)
或get_term_by('slug', $term_slug, $taxonomy)
获取单个术语对象。术语“对象”将具有以下属性:
Get the single term object using
get_term($term_ID, $taxonomy)
, or alternativelyget_term_by('slug', $term_slug, $taxonomy)
.The term object will have, among other properties;