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.
- Open the file /wp-includes/category-template.php.
- 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.”) - Make changes in the array as follows:
- 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.
I 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. - 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
Learn more about working with a self-hosted WordPress 2.7 installation — or WordPress.com. Check out my WordPress courses on Lynda.com.
thanks! i have a little troubel with mine so found some usefull hints here in this post!
Maria,
This is a good reference but it would be much better to set the arguments within the cloud tag function. Your example modified the core WP files: One would have to remember to modify this file when a change/updgrade happens with WP.
Typically the cloud tag is going to be located in the sidebar.php file within the theme directory.
A couple of examples of the arguments:
Details on the cloud are described in the codex:
Template Tags/wp tag cloud
Rick
P.S. Have you been working with Child template themes within Wordpress. Child themes are a great aspect in that you can leave the files of the parent theme alone and inherit their style and function within the child theme. One can do all of their changes, edits and adjustments on the child theme files to customize the theme. Much easier to track changes.
Rick: This is a good point, and I agree that if you’re modifying the sidebar template file to insert the tag cloud widget, your way IS the way to go. However, I’m providing instructions for modifying the default Tag Cloud widget for folks who want to use widgets rather than hard-code content in their sidebar theme.
Agreed also about the biggest drawback of my method: that you must remember to modify the
category-template.phpfile each time you upgrade WordPress. I think there IS a way around this, but I haven’t had time to research it.I did spend a few minutes trying to find a hook to the default tag cloud widget but couldn’t find anything simpler than creating another widget. Much more complicated than your change.
Configurable Tag Cloud (CTC) is a plug-in which provides a Widget for the Tag Cloud. CTC provides a panel to configure the tag cloud parameters. (My test showed it worked with WP 2.7).
Here is an interesting tag cloud plug-in:
WP Cumulus Flash Based Tag Cloud
RickHap: Thanks for the CTC info and link. I’d much rather use something like that than have to manually hack code each time I want to make a change or I update WordPress.
Worked flawlessly on my site, just as advertised. Thanks!
Take a lesson from Drupal and never hack core or end up having to re-do everything you customized every time you upgrade.
Figure out a way to do it via the functions script or find a plug-in. Otherwise you are creating more work for yourself or eliminating a seamless upgrade path.
Good info nonetheless, but you have to be careful with the changes you make.
Dave´s last blog post: Cinco de Mayo
Dave: You’re right, of course. The problem with hacking — even a simple hack like this — is that when you update the software, the hack is overwritten with the new files.
I’ve since found a plugin that does what I need: Simple Tags. Not only does it offer a customizable Tag Cloud widget, but it adds a bunch of tag management features.
Thanks for the reality check!
You guys rock. Your discussion has saved me many hours of work. So simple when we all share what we love!!