|
把下面代码加到functions.php文件中- //彩色标签云函数开始
- function colorCloud($text) {
- $text=preg_replace_callback('|<a (.+?)>|i','colorCloudCallback',$text);
- return $text;
- }
- function colorCloudCallback($matches) {
- $text=$matches[1];
- $color=dechex(rand(0,16577111));
- $pattern='/style=(\'|")(.*)(\'|")/i';
- $text=preg_replace($pattern,"style="color:#{$color};$2;"",$text);
- return "<a $text>";
- }
- add_filter('wp_tag_cloud','colorCloud',1);
复制代码 |
|