wordpress tip: spice up your tag cloud
This will take your tag cloud and use random colors, instead of 1 color which is the default output.
add this to your themes functions.php file
Code:
function colorcloud($text) {
$text = preg_replace_callback('|<a (.+?)>|i', 'colorcallback', $text);
return $text;
}
function colorcallback($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);
and in your sidebar place the wp_tag_cloud() function.
Code:
<?php wp_tag_cloud('smallest=8&largest=24&number=50'); ?>
|