在 WordPress 中,我使用此功能显示所有标签
<?php
$tags = get_tags();
$html = '<div class="post_tags">';
foreach ( $tags as $tag ) {
$tag_link = get_tag_link( $tag->term_id );
$html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
$html .= "{$tag->name}</a>";
}
$html .= '</div>';
echo $html;
?>
然后打印出所有标签。
除了显示所有标签之外,有没有一种方法可以说我希望它显示哪些标签并链接到?
我也试过这个
<?php
$tags = query_posts('tag=html');
$html = '<div class="post_tags">';
foreach ( $tags as $tag ) {
$tag_link = get_tag_link( $tag->term_id );
$html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
$html .= "{$tag->name}</a>";
}
$html .= '</div>';
echo $html;
?>
我确定答案在此页面上,但我无法提出解决方案http://codex.wordpress.org/Function_Reference/get_the_tags