Colorful Tag Cloud without Any Plugin
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.
Firstly, open the functions.php file in your theme directory, copy the subjacent code and paste it in your functions.php file.
//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.
<?php wp_tag_cloud( 'smallest=8&largest=24&number=50' ); ?>
via:
http://www.aowaa.com/how-to-add-colorful-tag-cloud-without-any-plugin-in-wordpress/
http://zou.lu/colorful-tag-cloud-without-any-plugin-in-wordpress/
http://wanwp.com/tips-tricks/howto-make-a-colorful-tag-cloud/
Add comment June 12th, 2010
