// WordPress Configurable Tag Cloud Plugin

Jump to comments

NEW! Version 5.2 released. See below for changelog/notes.

Frustrated by the built-in tag cloud widget in WordPress 2.3? I was. So I wrote my own that not only gives you configuration options (which are sorely needed), you also get font and color control of the generated links.

Download: Configurable Tag Cloud Plugin
Mirror: CTC at WP Extend

Translations:
CTC Version 4.1 (Hebrew Translation) – Hebrew translation by Meir Pinto.

Plugin Notes:
Changelog:

ver. 5.2 – Released November 13, 2009
Changes:

  • Fix: Moved plugin files out of folder so WP Extend plugin update system can be used.
  • Fix: Got rid of PHP short tags.
  • Change: Added default class to cloud link elements. Class name is “ctc-tag”. Thanks to Raafi Rivero (desedo.com) for bug report and link class suggestion.

ver. 5.1 – Released August 2nd, 2009
Changes:

  • Fix: Fixed issue with default options not being set on plugin activation.

ver. 5.0 – Released July 31st, 2009
Changes:

  • Change: Modularized plugin to better handle troubleshooting issues.
  • Change: Widget upgraded to new Widget API. Retained backwards-compatibility with older versions of WordPress.
  • Change: Widget is now fully multi-widget compliant. You can now have multiple cloud widgets active with different settings for each.
  • Change: Added support for limiting cloud by number of posts in each tag. Both an upper and lower limit are supported. Defaults for limits are 0 (lower) and 100 (upper).
  • Change: Can now choose to not show tags (i.e., to show a category cloud).
  • Change: Added “dropdown” cloud format. Thanks to Scott Bradford of Scott Bradford Creative Enterprises for the change.

ver. 4.5 – Released April 18th, 2008
Changes:

  • Added option menu for configuring the plugin when using the template tag. Options set via the control panel can be over-ridden using parameters in the tag. Widget and non-widget options are separate, giving you the ability to have multiple clouds with different options.
  • Removed limit for number of tags returned by default. The plugin will now show ALL tags in your blog unless you specify a limit.
  • Removed “Array” cloud format from widget control panel. More processing needs to be done to the array after creation in order to display, and you can’t do that when using as a widget. This was causing confusion, so it was removed.

ver. 4.1 – Released February 22nd, 2008
Changes:

  • Added random sort feature for cloud
  • Fixed error resulting in links for categories in the cloud not being generated correctly.

ver. 4.0 – Released February 15th, 2008
Changes:

  • Added support for categories in the cloud. You can choose whether or not to show categories in the cloud, and whether to show empty categories.
  • Not assigning any colors in the widget control panel or the template tag will now make the cloud links use the defined CSS link color. If only one color is supplied, your links will be that color.

ver. 3.2 – Released February 12th, 2008
Changes:

  • Fixed problem with spaces after tags being underlined if using the “text-decoration: underline” style in your stylesheet.

ver. 3.1 – Released February 6th, 2008
Changes:

  • Added option to use array for cloud format (see below for example)

ver. 3.0 – Released December 2nd, 2007
Changes:

  • Can now be used without widgets (see below for more info)
  • Added option to display post count after tags

ver. 2.51 – Released October 19th, 2007
Changes:

  • Fixed bug that prevented tag count option from working correctly. It came down to a bad variable name.

ver. 2.5 – Released October 16th, 2007
Changes:

  • Added div surrounding tag cloud for styling purposes.
  • Fixed bug that would produce “Divide by zero” errors on display if you didn’t input anything for smallest and/or largest font size in config form.

ver. 2.0 – Released October 3rd, 2007
Changes:

  • Added code necessary to enable coloring tag links by weight.
  • Changed from using WordPress-native tag cloud function to internal widget function to generate tag cloud (required for color).
  • Removed “array” format. I’m not sure it would be of any use running in a widget, but if you need it, the call to add it to the dropdown can be found commented out at line 217 in tag-cloud.php.
  • Added brief help text to the right of each field in the form.

ver. 1.0 – Initial Release, September 22, 2007
Initial release of widget. Relied on the built-in WordPress tag cloud function.

CTC 4.0 config screenshot

Installation:
Upload the tag_cloud folder to your wp-content/plugins directory, and activate via the Plugins admin panel.

Upgrades:
I recommend using the automated plugin upgrade features in WordPress, but to upgrrade manually, disable plugin in Admin panel. Delete tag-cloud.php, upload the new tag_cloud folder, and enable in admin panel.

Use:
Widget Defaults:

Title Tags
Number of Tags to Show all
Minimum number of posts for a tag or category to show in the cloud 0
Maximum number of posts for a tag or category to show in the cloud 100
Number of Tags to Display 45
Font Display Unit Points
Smallest Font Size 8
Largest Font Size 22
Min. Tag Color none (see note below)
Max. Tag Color none (see note below)
Cloud Format Flat
Categories in cloud? No
Show empty? No
Display Post Count? No
Sort By Name
Sort Order Ascending

After installing/upgrading, enable the widget via the Plugins tab. This will give you a new button in the Widgets control panel labeled “CTC” (Configurable Tag Cloud was too long for the button). Drag it into your sidebar list, and configure the options to your liking. If you want to keep the defaults for the widget, just leave everything as-is.

The widget gives you the capability to modify almost all of the settings of the wp_tag_cloud() template tag. At this point, you can do everything but exclude tags from the cloud display. I’m still working on this, but at this point, all the options most users would want are represented.

Notes about limiting the tags that are shown in the cloud (New in 5.0): You can now choose to limit the tags shown in the cloud by the number of posts they are attached to. For example, say you have one or two tags that are attached to 20 posts, but the rest only have one or two posts. Previously, these tags would be large, with the rest fairly small. Now, you can tell the plugin that you want to exclude tags that have more than 10 posts, and those tags will be excluded from the cloud, with the rest following a (hopefully) smoother gradient in both color and size. This also works for tags with fewer than a specified number of posts. The defaults as defined in the plugin are a maximum of 100 and a minimum of 0.

Notes about color (new in 2.0, updated in 4.0): If left blank, the tag cloud link colors will default to your assigned CSS color from the stylesheet. If you use one color (either min or max, doesn’t matter) only, your tag cloud links will be displayed using that color.

Notes about styling the tag cloud (new in 2.5, updated in 4.0): The div surrounding the tag cloud has it’s class set as “ctc”. You should be able to modify any property of this class via CSS except for font-size (this is set with inline styles in the links themselves). Tag link color can now be controlled via the stylesheet by leaving both the min and max colors blank in the configuration and setting a color in your stylesheet.

Notes about non-widget use (new in 3.0): Just like the widget, this function replaces the built-in wp_tag_cloud function with options for color, font size, etc. The function uses the standard query string format for arguments.

To use, simply insert the function call into your template file (most likely sidebar.php, but you can put it wherever you like), and adjust the options accordingly.

Example

<?php ctc('smallest=10&largest=28&unit=px&mincolor=#c0c0c0&maxcolor=#000000&showcount=yes'); ?>

This would show a cloud with font sizes from 10 to 28 pixels, a color gradient of #c0c0c0 to #000000, and post counts after each tag.

Notes about array use (new in 3.1): I’m still undecided on why you would want to use an array, but it was requested, so it has been added. You call the function via the template tag just as you would for non-array use, but assigning the output to a variable. I’ll give you an example.

<?php
$tags = ctc('format=array&smallest=10&largest=28&unit=px&mincolor=#c0c0c0&maxcolor=#000000&showcount=yes');
foreach ($tags as $tag) {
echo $tag."\n"
}
?>

This would show a cloud just like the first example, but using an array to output it to the page.

CTC Ver. 4.5 Options Screen

Parameters for template tag:

PARAMETER FUNCTION DEFAULT VALUE
smallest=# Smallest font size to use 8
largest=# Largest font size to use 22
minnum=# Minimum number of posts for a tag or category to show in the cloud 0
maxnum=# Maximum number of posts for a tag or category to show in the cloud 100
unit=pt|em|%|px Unit for font size pt
mincolor=#xxxxxx Low color for gradient none
maxcolor=#xxxxxx High color for gradient none
format=flat|list|array|drop Format for tag cloud flat
number=# Number of tags to show 45
orderby=name|count|rand Sort field for tags name
order=ASC|DESC Order of cloud ASC
showcount=yes|no Show post count after tags no
showcats=yes|no Show categories in cloud no
empty=yes|no Show empty categories no

Troubleshooting:
If for some reason you run into trouble, please don’t hesitate to email me or post a comment on this page.