看见wp的标签云的标签很多是根据标签数量来控制标签字体大小的主题,所以我想zblog php 也应该能实现,所以我就看wp的标签云的该段代码。所以整合到zblog php里去。写个函数就好了。函数如下:
function tqingxin_tags(){ global $zbp; $str = ''; $array = $zbp->GetTagList(array('*'),'',array('tag_Count'=>'DESC'),''); $counts = array(); foreach ( (array) $array as $key => $tag ) { $counts[ $key ] = $tag->Count; } $min_count = min( $counts ); $spread = max( $counts ) - $min_count; $largest=25; $smallest=8; if ( $spread <= 0 ) $spread = 1; $font_spread = $largest - $smallest; if ( $font_spread < 0 ) $font_spread = 1; $font_step = $font_spread / $spread; foreach ($array as $tag) { $zz= $smallest + ( ( $tag->Count - $min_count ) * $font_step ) ; $str .='<span style="font-size: '.$zz.'px;"><a href="'.$tag->Url.'" title="文章数:'.$tag->Count.'" target="_blank">'.$tag->Name.'</a></span> '; } return $str; }
前台调用:
{php}echo tqingxin_tags(){/php}
效果:
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请通知我们,一经查实,本站将立刻删除。