Golehe.net Go乐呵| PHP && Python… | Since 2009.11.25 嘛钱不钱的,乐呵乐呵得了

不用标签实现wordpress彩色标签云

01.11.2010 · Posted in 未分类

效果如图:

代码如下:

<?php
function colorCloud($text) {
$text = preg_replace_callback(‘|<a (.+?)>|i’, ‘colorCloudCallback’, $text);
return $text;
}
function colorCloudCallback($matches) {
$text = $matches[1];
$color = dechex(rand(0,16777215));
$pattern = ‘/style=(\’|\”)(.*)(\’|\”)/i’;
$text = preg_replace($pattern, “style=\”color:#{$color};$2;\”, $text);
return “<a $text>”;
}
add_filter(‘wp_tag_cloud’, ‘colorCloud’, 1);
?>

将代码写到functions.php中,(注意<?php ?>开关)然后在小工具里,添加一个默认的标签云工具就可以了。注意:可能会和wp colums FLASH标签云冲突


文章转自互联网。。。非本站原创。

效果见本站adsimple主题边栏。

Related Posts with Thumbnails

No related posts.

»>

1 回复 在 “不用标签实现wordpress彩色标签云”

  1. [...] 另:此PHP代码为不用插件实现wordpress标签云 [...]

Leave a Reply

:wink: :-| :-x :twisted: :) 8-O :( :roll: :-P :oops: :-o :mrgreen: :lol: :idea: :-D :evil: :cry: 8) :arrow: :-? :?: :!: