WordPress 正文添加标签选项

对于部分wp主题在正文页没有标签现实,这里提供两个简单的代码增加显示标签的功能。

1:代码比较简单就一行

标签: <?php the_tags(__(”), ‘, ‘); ?>

修改single.php,放入到the_content代码之后就可以了。

2:代码比较多,放入同样的位置即可:

$posttags = get_the_tags();
$content .= “[ 标签: ";
if ($posttags) {
$tag_i = 0;
foreach($posttags as $tag) {
if($tag_i > 0) { $content .= ', '; }
$content .= '<a href="' . get_tag_link($tag->term_id) . '">' .$tag->name .  '</a>';
$tag_i++;
}
}
else {
$content .=  '无';
}
content .= " ] <br>”;
$content .= “[ 固定链接:<a href='" . get_permalink() . "'>" . get_permalink() . "</a> ]<br/>”;
☆版权☆

* 网站名称:obaby@mars
* 网址:https://h4ck.org.cn/
* 个性:https://oba.by/
* 本文标题: 《WordPress 正文添加标签选项》
* 本文链接:https://image.h4ck.org.cn/2009/09/264
* 短链接:https://oba.by/?p=264
* 转载文章请标明文章来源,原文标题以及原文链接。请遵从 《署名-非商业性使用-相同方式共享 2.5 中国大陆 (CC BY-NC-SA 2.5 CN) 》许可协议。


You may also like

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注