WP调用彩色Tag标签
使用WP博客主题的更换即会遇到tag的问题,这里提供不使用插件,可使WordPress边栏调用彩色Tag标签
将以下代码放入主题包 functions.php 文件中(如果没有这个文件,新建保存即可):
—————-线内—————-
function colorCloud($text) {
$text = preg_replace_callback(‘||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 “”;
}
add_filter(‘wp_tag_cloud’, ‘colorCloud’, 1); (more…)