How to Add Colorful Tag Cloud without Any Plugin in Wordpress
The tags cloud page can show the most discussed topics to your readers.Using the wp_tag_cloud function can add the tag cloud in your wordpress page. You can learn more about wp_tag_cloud function from wordpress codex. But the default tag cloud in wordpress show in single color, it’s blankness and hard to read. So if you make the tag cloud show up colorful, the readers can easily get your main topics and know what are you talking about in your blog.

Colorful Tag Cloud
If you have installed the simple tags wordpress plugin, you can use the function <?php st_tag_cloud(); ?> to add the colorful tag cloud. But if you didn’t, we can tell you an easily way to add the colorful tag cloud without any plugin in wordpress. You can see the demo from my colorful tag cloud page.
Firstly, open the functions.php file in your theme directory, copy the subjacent code and paste it in your functions.php file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | //Start of colorful tag cloud 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); //End of colorful tag cloud |
Add the subjacent code to where you want the tag cloud show. And it’s done, you can see the colorful tag cloud in your wordpress blog now.
1 | <?php wp_tag_cloud( 'smallest=8&largest=24&number=50' ); ?> |









