This color tag cloud effect can be displayed by modifying simple tags.
1. Find the function of Getcolorbyscale first in simple-tags.client.php:
| The code is as follows |
Copy Code |
function Getcolorbyscale ($scale _color, $min _color, $max _color) |
2. Comment out (or delete) Getcolorbyscale The following statement in this function:
| code is as follows |
copy code |
| $scale _color = $scale _color/100; $minr = Hexdec (substr ($min _color, 1, 2)); br> $ming = Hexdec (substr ($min _color, 3, 2)); $minb = Hexdec (substr ($min _color, 5, 2)); $maxr = Hexdec (substr ($max _color, 1, 2)); $maxg = Hexdec (substr ($max _color, 3, 2)); $maxb = Hexdec (substr ($max _color, 5, 2)); $r = Dechex (Intval ($MAXR-$MINR) * $scale _color) + $minr)); $g = Dechex (Intval ($MAXG-$ming) * $scale _color) + $ming)); $b = Dechex (Intval ($MAXB-$minb) * $scale _color) + $minb); 3. Add the following code: //colorful Tag Cloud start $r = Dechex (rand (0,255)); $g = Dechex (rand (0,196)); $b = Dechex (rand (0,255)); |
Colorful tag Cloud end as to how many labels to display, how to arrange, popular tags and ordinary labels are the size of the font, can be in the background of simple tags in the options set.
Method Two, if the above method is not possible we can refer to the following method.
Background edit the functions.php of the subject, enter the following code
| The code is as follows |
Copy Code |
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); |
As you can see, the color is random and can be modified $color = Dechex (rand (0,16777215)); This line to modify the scope, so it is very ostentatious haha.
Then invoke the following code in the sidebar sidebar.php:
| The code is as follows |
Copy Code |
<?php wp_tag_cloud (' smallest=8&largest=24&number=50 ');?> |
Can, 8 is the smallest tag font size (with the least tag), 24 is the largest (with the most of the tag), 50 is the number of tag, you can modify it.