WordPress tag clouds can be used as an alternative navigation for readers to quickly access content of the same topic on your website. The more articles your write with the same tags the bigger those words appear in your tag cloud. For instance, I seem to write a lot about WordPress and Twitter, so those words are quite large in my tag cloud.
But tag clouds can get really messy over time, especially if you or your site admins use several tags for an article and never use those tags again. Lots of tiny words in your tag cloud can look really messy. If you intend to use those tags again it’s a good idea to customise your tag cloud.
Change the font size
By default, the tag cloud displays fonts by point (pt); the smallest being 8pt and the largest being 22pt. You can change the size of the fonts so that all the words are the same size or you can increase the size of the smallest words so that they don’t look so bad. To do this you will need to edit your theme’s functions.php file.
Go to Appearance > Editor > Functions.php and add this code at the end:
function custom_tag_cloud_widget($args) {
$args[‘largest’] = 20; //largest tag
$args[‘smallest’] = 16; //smallest tag
$args[‘unit’] = ‘px’; //tag font unit
return $args;
}
add_filter( ‘widget_tag_cloud_args’, ‘custom_tag_cloud_widget’ );
All you need to do is change the font sizes in this example 20 is the largest and 16 is the smallest.
Limit tags to most popular
A good way around the overuse of tags is to decide on agreed tags and try to avoid tag creep. But if you have several administrators who are tag happy, you can limit the amount of tags shown on your site so that just the popular words are shown. Going back to your functions.php file you just need to add this code:
function custom_tag_cloud_widget($args) {
$args[‘number’] = 0; //adding a 0 will display all tags
$args[‘largest’] = 18; //largest tag
$args[‘smallest’] = 10; //smallest tag
$args[‘unit’] = ‘px’; //tag font unit
return $args;
}
add_filter( ‘widget_tag_cloud_args’, ‘custom_tag_cloud_widget’ );
By default, WordPress only shows 45 tags but you can increase this by setting $args[‘number’] to 0 (zero). Or you can reduce it to a tidy manageable number like 10 or 20.
Hopefully, now your tag cloud will look less messy and as you write more about the same topics the popular tags will change and grow.
Leave a Reply