在使用 get_the_tag_list($ID) WordPress 方面需要帮助 [英] need help in using get_the_tag_list($ID) WordPress

查看:16
本文介绍了在使用 get_the_tag_list($ID) WordPress 方面需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个新的 WordPress 模板,我只想以文本格式获取与帖子关联的标签列表.我正在使用

get_the_tag_list($id)

但问题在于它返回 URL 和文本.有什么方法可以将标签的文本"附加到以逗号分隔的帖子上?

tag1、tag2、tag3、tag4 等没有 URL 而只是文本?

谢谢

解决方案

name .',';}}?>

来源:http://codex.wordpress.org/Template_Tags/get_the_tags

I am making a new WordPress template and I want to just get, in text format, the list of tags associated with a post. I am using

get_the_tag_list($id)

But the problem is that it returns the URL as well as the text. Is there any way to just get the "text" of tags attached to a post seperated by a comma ?

i.e. tag1, tag2, tag3, tag4 etc without the URL and just as text?

Thanks

解决方案

<?php
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
echo $tag->name . ','; 
}
}
?>

Source: http://codex.wordpress.org/Template_Tags/get_the_tags

这篇关于在使用 get_the_tag_list($ID) WordPress 方面需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆