文章标签 ‘彩色标签云’
-
不用插件实现WordPress彩色标签云
1、点击“外观”选项卡下的“编辑”选项进入主题编辑界面 2、选择functions.php文件进行编辑,在functions.php文件中的<?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); 可以自行修改 $color = dechex(rand(0,16777215)); 这行来修改范围。 3、然后在要显...
+阅读全文+
