操作步骤:
1)到主机后台的「主题根目录」新建一个名为「functions.php」的文件(如有的话直接粘贴代码);
//WordPress圆角彩色背景标签云
function colorCloud($text) {
$text = preg_replace_callback('|<a (.+?)>|i', 'colorCloudCallback', $text);
return $text;
}
function colorCloudCallback($matches) {
$text = $matches[1];
$colors = array('F99','C9C','F96','6CC','6C9','37A7FF','B0D686','E6CC6E');
$color=$colors[dechex(rand(0,7))];
$pattern = '/style=(\'|\")(.*)(\'|\")/i';
$text = preg_replace($pattern, "style=\"display: inline-block; *display: inline; *zoom: 1; color: #fff; padding: 1px 5px; margin: 0 5px 5px 0; background-color: #{$color}; border-radius: 3px; -webkit-transition: background-color .4s linear; -moz-transition: background-color .4s linear; transition: background-color .4s linear;\"", $text);
$pattern = '/style=(\'|\")(.*)(\'|\")/i';
return "<a $text>";
}
add_filter('wp_tag_cloud', 'colorCloud', 1);
2)点击「编辑」然后粘贴代码点击「提交」;
3)WP后台写文章是插入标签(建议一个文章一个标签);
© 版权声明
文章版权归作者所有,未经允许请勿转载。 本站声明:(视频类)源码、图片、链接仅为开发学习交流使用,请勿用做其他违法用途! 请在法律允许的范围内使用素材 上传数据均是个人行为,与本站无关。
THE END
喜欢就支持一下吧
Mark6月前0
Thanks for your blog, nice to read. Do not stop.Maxblue.de1年前0
Great content! Keep up the good work!