wordpress获取tag和防止乱码

文章描述:

WordPress如何处理tag标签链接里面的乱码

 

全部tag

<?php 
$all_tags = get_tags();
foreach($all_tags as $tag) {
    $tag_id = $tag->term_id;
    $tag_name = $tag->name;
?>
<a href="<?=urldecode(get_tag_link($tag_id));?>"><?=$tag_name;?></a>
<?php
}
?>

当前文章tag

<?php
$all_the_tags = wp_get_post_tags($post->ID);
if($all_the_tags){
    foreach($all_the_tags as $this_tag) {
        $tag_id = $this_tag->term_id;
        $tag_name = $this_tag->name;
        ?>
        <a rel="tag" href="<?=urldecode(get_tag_link($tag_id));?>"><?=$tag_name;?></a>
        <?php
    }
}
?>

 

发布时间:2021/06/21

发表评论