Php 列出WordPress博客中的所有标签
我需要列出在WordPress博客中至少有一篇文章的所有标签 该列表是关于完整博客的,与当前帖子无关 您将使用什么代码?$tags=get_tags();Php 列出WordPress博客中的所有标签,php,wordpress,tags,Php,Wordpress,Tags,我需要列出在WordPress博客中至少有一篇文章的所有标签 该列表是关于完整博客的,与当前帖子无关 您将使用什么代码?$tags=get_tags(); $tags = get_tags(); $html = '<ul>'; foreach ( $tags as $tag ) { if($tag->slug != "migliori"){ $tag_link = get_tag_link( $tag->term_id ); $html .= "<li><
$tags = get_tags();
$html = '<ul>';
foreach ( $tags as $tag ) {
if($tag->slug != "migliori"){
$tag_link = get_tag_link( $tag->term_id );
$html .= "<li><a href='{$tag_link}' class='{$tag->slug}'>";
$html .= "{$tag->name}</a></li>";
}
}
$html .= '</ul>';
echo $html;
$html=“- ”;
foreach($tags作为$tag){
如果($tag->slug!=“migliori”){
$tag\u link=get\u tag\u link($tag->term\u id);
$html.=“”;
}
}
$html.='
这很有效。我试过这个,为我工作
<?php
$tags = get_tags();
if ($tags) {
?><ul class="tags"><?php
foreach ($tags as $tag) {
echo '<li><a href="' . get_tag_link( $tag->term_id ) . '"
title="' . sprintf( __( "View all posts in %s" ), $tag-
>name ) . '" ' . '>' . $tag->name.'</a></li>';
}
echo '<li><a href="#">View All</a><span class="arrow"></span>
</li>'; ?></ul>
<?php }?>
编辑此代码并为我工作!!!
您尝试了什么代码?你至少在谷歌上搜索过类似“Wordpress显示所有标签”的东西吗?可能是重复的,你能给这个代码添加一些解释吗?对我来说,它看起来像是其他答案的乱码副本,但是这个代码显示了所有的标签。但是我展示了一个特殊的单标签列表。你能用这个密码吗。
edit this code and work for me !!!
<ul class="tags">
<?php
$tags = get_tags('post_tag'); //taxonomy=post_tag
//echo "<pre>";
//print_r($tags);
//var_dump($tags);
if ( $tags ) :
foreach ( $tags as $tag ) : ?>
<li><a class="tag" href="<?php echo esc_url( get_tag_link( $tag->term_id ) ); ?>" title="<?php echo esc_attr( $tag->name ); ?>"><?php echo esc_html( $tag->name ); ?></a></li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
<ul class="tag-manually">
<?php
$tags = get_tags('post_tag'); //taxonomy=post_tag
if ( $tags ) :
foreach ( $tags as $tag ) : ?>
<li class="tag-item-manually"><a class="tag" href="<?php echo esc_url( get_tag_link( $tag->term_id ) ); ?>" title="<?php echo esc_attr( $tag->name ); ?>"><?php echo esc_html( $tag->name ); ?></a></li>
<?php endforeach; ?>
<?php endif; ?>
</ul>