[caption
id
="attachment_11376
" align
="aligncenter
" width
="389"]
WordPress
主题美化-7B2美化彩色标签云[/caption
]
以下代码均添加于子主题根目录下的 functions
.php
中
//
WordPress
圆角彩色背景标签云function
colorCloud
($text
) {$
text
=preg_replace_callback
(, '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
.4slinear
; -moz
-transition
:background
-color
.4slinear
;transition
:background
-color
.4slinear
;\"", $text
);$
pattern
= '/style
=(\'|\")(.*)(\'|\")/i
';return
;}
add_filter
('wp_tag_cloud
', 'colorCloud
', 1);
一键复制
转载请注明:汇站网 » WordPress
主题美化-7B2 美化颜色标签云