To modify the wordpress label font size:
In the Cpanel panel, open "wp-includes"→"category-template.php" in turn, locate Wp_tag_cloud,
1234567 |
function wp_tag_cloud(
$args = ” ) {
$defaults =
array
(
‘smallest’ => 8, ‘largest’ => 22, ‘unit’ => ‘pt’, ‘number’ => 45,
‘format’ => ‘flat’, ‘separator’ => “\n”, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’,
‘exclude’ => ”, ‘
include
’ => ”, ‘link’ => ‘view’, ‘taxonomy’ => ‘post_tag’, ‘
echo
’ => true
);
$args = wp_parse_args(
$args
,
$defaults );
|
which
Smallest: the label font size with the least number of times, the default is "8";
Largest: the most frequently used label font size, default is "22";
In fact, many of the online tutorials on smallest and largest are not accurate, the Internet is said to be smallest to indicate the minimum font size of the label, largest the maximum font size, so the first time I only wrote an article, of course, the number of use of the label is 1 times, So the labels are the same size, and I didn't understand why the labels were the same size.
Unit: Label font size units, default is "pt";
Number: The label cloud shows the amount of labels, default is "45";
Format: "flat" How a display method did not understand;
Separator: The delimiter between tags, by default is a space;
ORDER BY: The label sequence, by default is sorted by name;
Order: Ascending or descending.
After the modification, save overwriting the original file.
To Modify the wordpress tag color:
Open functions.php and add the following code:
12345678910111213 |
function colorCloud(
$text
) {
$text = preg_replace_callback(‘|<a>|i’, ‘colorCloudCallback’,
$text
);
return $text
;
}
function colorCloudCallback(
$matches
) {
$text =
$matches
[1];
$colors
=
array
(‘ff3300′,’0517c2′,’0fc317′,’e7cc17′,’601165′,’ffb900′,’f74e1e’,’00a4ef’,’7fba00′);
//这里设置了一个颜色数组
$color
=
$colors
[
dechex
(rand(0,3))];
//通过这里设置选取哪几个数组颜色来轮番显示
$pattern = ‘/style=(\’|\”)(.*)(\’|\”)/i’;
$text = preg_replace(
$pattern
, “style=\”color:#{
$color
};
$2
;\””,
$text
);
return “</a><a>”;
}
add_filter(‘wp_tag_cloud’, ‘colorCloud’, 1);</a>
|
which
1 |
$colors = array (‘ff3300′,’0517c2′,’0fc317′,’e7cc17′,’601165′,’ffb900′,’f74e1e’,’00a4ef’,’7fba00′); |
is to control the color display method, according to their favorite color turns display, by default, you can also give a range to randomly display, such as:
1 |
$color = dechex (rand(0,16777215)); |
But the results of this random display are not good, because sometimes the color is very light, the label is not clear at all. Some colors do not like their own, rather than set a color for good
WordPress Modify Tag Cloud size and color