从 WordPress 函数中删除标签

发布于 2024-09-29 05:06:16 字数 179 浏览 8 评论 0原文

尝试打印我的自定义帖子类型的分类,但没有链接。尝试过,但似乎不起作用,有什么建议吗?

$text = the_terms($post->ID,'type','','',''); 
echo strip_tags($text);

任何帮助将不胜感激...我要开始打婴儿了。

Trying to print my custom post type's taxonomy but without the link. Tried this, but doesn't seem to work, any suggestions?

$text = the_terms($post->ID,'type','','',''); 
echo strip_tags($text);

Any help would be greatly appreciated... I'm about to start punching babies.

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

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

发布评论

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

评论(2

以往的大感动 2024-10-06 05:06:16

the_terms() 显示术语,但您无法将它们存储到变量中,因为它们是回显的。您应该尝试使用 get_terms()

$myterms = get_terms('category', 'orderby=count&hide_empty=0');

为了将来使用,the_something() 方法将特定内容打印到模板中,get_something() 方法返回内容,以便您可以将其存储到变量中。

the_terms() display the terms, but you cant store them into a variable because they are echoed. You should try get_terms() instead.

$myterms = get_terms('category', 'orderby=count&hide_empty=0');

For future use, the the_something() methods print the specific content ito the template and the get_something() methods return the content so you can store it into a variable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文