How To Customize WordPress’s Tag Cloud Widget

You don’t have to use it with default settings.

If you use WordPress widgets on your self-hosted WordPress blog, you may not be fully satisfied with the way the Tag Cloud widget looks and works on your site. I know I wasn’t. The maximum font size was too large for the most commonly used tag (helicopters, on my blog) to fit into the column in which I’d put it. Since I wanted my tag cloud in the narrow column in which it resided, I had to make a change.

The answer is to modify the wp_tag_cloud function in the category-template.php file. It’s remarkably easy to do. Here’s how.

  1. Open the file /wp-includes/category-template.php.
  2. Scroll down to the line that begins function wp_tag_cloud. If you’re using WordPress 2.7 and haven’t made any other changes to this file, you should find it at line 552. (You can always do a search for it; I found the general area by searching for “tag cloud.”)
  3. Make changes in the array as follows:

    Tag Cloud Function

    • To specify the smallest font size, set the value after ‘smallest’. The default is 8 points.
    • To specify the largest font size, set the value after ‘largest’. The default size is 22 points.
    • To specify the maximum number of tags included in the cloud, set the value after ‘number’. The default number of tags is 45.

    My Tag CloudI changed my settings to 6, 16, and 75 respectively. You can see the results in the screenshot here, as well as in the sidebar for my blog, An Eclectic Mind.

  4. Overwrite the existing file with the changed file.

When you reload a page that uses the Tag Cloud widget, your changes should appear immediately.

Keep in mind that if WordPress is updated and the file you changed is replaced, you may have to repeat these steps to reset your defaults.

Learn More

Lynda.comLearn more about working with a self-hosted WordPress 2.7 installation — or WordPress.com. Check out my WordPress courses on Lynda.com.

4 Great Articles about WordPress 2.7

Why reinvent the wheel?

WordPress LogoLast night, the folks at Automattic updated WordPress.com to version 2.7. The self-hosted version of WordPress is still in beta, although Release Candidate 1 (RC1) was released two days ago.

I’ve been working with WordPress 2.7 for about two weeks now (since Beta 2) and am absolutely thrilled with it. The Dashboard and administrator interface has been completely reworked to make it not only more useful, but easier to navigate. Sure, a lot of folks will be grumbling about the change from horizontal-on-top to vertical-on-left navigation, but when you look beyond the obvious, you see a true user interface improvement.

There are plenty of other new features, too. But rather than write my own article about them, here are links to five other articles written by folks who clearly love WordPress as much as I do. Read up, upgrade, and enjoy!

2.7 Gets Here in 2 Days! by Jane Wells on the WordPress.com blog was the first official announcement of 2.7′s upcoming appearance on WordPress.com. Jane helps fuel the excitement with a great description of the new features.

10 Things You Need to Know about WordPress 2.7 by Aaron Brazell on Technosailor states, “This is not your grandma’s WordPress!” (Not sure if I should be offended by this; there’s a chance I might be old enough to be his mother.) He then goes on to describe and state his opinions of the new features.

WordPress 2.7 – 20 Must See Features by Sean P. Aune on Mashable lists the 20 features he finds most notable with a few screen shots.

WordPress 2.7 arrives Thursday night is a shorter and more to-the-point piece by Joshn Lowensohn on cnet news. It links back to the first article here (which I also think is the best) for a full discussion of features.

I’ll be writing a bit about WordPress for Maria’s Guides as I find new tricks and tips to share. I’ll also be revising my Lynda.com training material to cover the new features available on WordPress.com.

If you have specific topics you’d like to see me cover, please use the Comments link or form for this post to list them. Please — no tech support questions for a weird problem you might be having; that’s what WordPress’s support forum are for. I’m interested in addressing “how to” questions, although I can’t promise to answer every one I receive.