Off the grid is the default tag cloud tag cloud wp,Sizes,Color is actually very unified,This does not look very beautiful。
Is there any way to make it look better tag cloud? In fact, it is there,There are many plug-ins,All kinds,But for a tag cloud,Is again in the fast flip add a plugin seems quite wasteful。
So I found some simple ways to not use plug-in also implements the color tag cloud,This would seem better。
This is accomplished by such:
Edit the corresponding theme in the background functions.php
In the end add the following inside
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?php function colorCloud($text) { <span style="color: #ffffff;"> </span $text = preg_replace_callback('|<a (.+?)>|i', 'colorCloudCallback', $text); return $text; } function colorCloudCallback($matches) { $text = $matches[1]; $color = dechex(rand(0,16777215)); $pattern = '/style=(\'|\")(.*)(\'|\")/i'; <span style="color: #ffffff;"> </span> $text = preg_replace($pattern, "style=\"color:#{$color};$2;\"", $text); return "<a $text>"; } add_filter('wp_tag_cloud', 'colorCloud', 1); ?> |
After saving gadgets in the theme directly dragged into the default tag cloud like,If you already use,Then refresh the page to direct ~
Original article written by LogStudio:R0uter's Blog » Color tag cloud WordPress without a plugin
Reproduced Please keep the source and description link:https://www.logcg.com/archives/235.html