A tiny plugin to change the annoying minimum and maximum font sizes used by the default tag cloud widget in WordPress.
One of the annoyances about the default tag cloud widget in WordPress is that there is no easy way to change the minimum and maximum font size that the widget uses. While the recent release of WordPress 2.8 doesn’t add any UI to change those sizes, it’s now easier to change them than before.
WordPress 2.8 adds a new widget_tag_cloud_args
filter, which you can use to override the default arguments that are passed to the wp_tag_cloud
function. The filter provides a keyed array, where the smallest
, largest
, and unit
keys represent the smallest font size, the largest font size, and the unit (‘pt’, ‘em’, ‘px’, etc) used by the default tag cloud widget.
You can change the minimum and maximum font size that the default tag cloud widget uses in WordPress 2.8 by creating a new plugin that hooks that filter as explained below.
Step-by-Step
Create a new text file called tag-cloud-resizer.php
. Copy and paste the following code into that text file, changing the relevant values as desired, and save it.
<?php
/*
Plugin Name: Tag Cloud Resizer
Plugin URI: https://chris.dziemborowicz.com/blog/2009/06/11/change-the-tag-cloud-font-size-in-wordpress-2-8/
Version: 1.2
Author: Chris Dziemborowicz
Author URI: https://chris.dziemborowicz.com/
Description: Changes the font sizes used by the tag cloud widget.
*/
function tcr_tag_cloud_filter($args = array()) {
$args['smallest'] = 8;
$args['largest'] = 12;
$args['unit'] = 'pt';
return $args;
}
add_filter('widget_tag_cloud_args', 'tcr_tag_cloud_filter', 90);
Create a new directory called tag-cloud-resizer
in your wp-content/plugins
directory, and upload tag-cloud-resizer.php
to the new directory. Finally, activate the plugin by logging into WordPress as an administrator, selecting Plugins from the menu, and selecting Activate for the Tag Cloud Resizer plugin.