将标签列表转换为 WordPress 中的标签云

问题描述 投票:0回答:1

经过多次黑客攻击后,我使用以下代码生成一个标签列表,用于名为“评论”的自定义帖子类型中的当前类别...

<?php
$cat_id = get_query_var('cat');
query_posts('post_type=review&posts_per_page=-1&cat='.$cat_id);
 if (have_posts()) :
 $posttags = array();
 while (have_posts()) : the_post();
   if( get_the_tag_list() ){
   $posttags = array_merge( $posttags, explode('||', get_the_tag_list('','||','')));
   }
 endwhile;
 $posttags = array_unique( $posttags );
 sort($posttags); //sort optional
   if( $posttags ) { 
    echo '<ul><li>';
   echo implode("</li>\n<li>", $posttags);
   echo '</li></ul>';
   }
 endif; wp_reset_query(); 
?>

这可以正常工作并输出正确的列表,但我想将此列表变成标签云,有人可以帮忙吗?

php wordpress tags
1个回答
0
投票

你可以用这个,

http://codex.wordpress.org/Function_Reference/wp_tag_cloud

或者使用一些插件,

https://wordpress.org/plugins/ultimate-tag-cloud-widget/

希望这对您有帮助

© www.soinside.com 2019 - 2024. All rights reserved.