对于部分wp主题在正文页没有标签现实,这里提供两个简单的代码增加显示标签的功能。
1:代码比较简单就一行
1 | 标签: <?php the_tags(__(”), ‘, ‘); ?> |
修改single.php,放入到the_content代码之后就可以了。
2:代码比较多,放入同样的位置即可:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | $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
本文标题: 《WordPress 正文添加标签选项》