WordPress Configurable Tag Cloud Plugin

This plugin is no longer under active development.

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:

TitleTags
Number of Tags to Showall
Minimum number of posts for a tag or category to show in the cloud0
Maximum number of posts for a tag or category to show in the cloud100
Number of Tags to Display45
Font Display UnitPoints
Smallest Font Size8
Largest Font Size22
Min. Tag Colornone (see note below)
Max. Tag Colornone (see note below)
Cloud FormatFlat
Categories in cloud?No
Show empty?No
Display Post Count?No
Sort ByName
Sort OrderAscending

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:

PARAMETERFUNCTIONDEFAULT VALUE
smallest=#Smallest font size to use8
largest=#Largest font size to use22
minnum=#Minimum number of posts for a tag or category to show in the cloud0
maxnum=#Maximum number of posts for a tag or category to show in the cloud100
unit=pt|em|%|pxUnit for font sizept
mincolor=#xxxxxxLow color for gradientnone
maxcolor=#xxxxxxHigh color for gradientnone
format=flat|list|array|dropFormat for tag cloudflat
number=#Number of tags to show45
orderby=name|count|randSort field for tagsname
order=ASC|DESCOrder of cloudASC
showcount=yes|noShow post count after tagsno
showcats=yes|noShow categories in cloudno
empty=yes|noShow empty categoriesno

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

263 thoughts on “WordPress Configurable Tag Cloud Plugin”

  1. Thank you, is the great plugins, but i need know how i cant insert a link for more tags, after i declared the total number of tags appear in the cloud. Is possible?

    1. The current version will work on WP 2.7.1. When I started convertingto the new Widgets API, I thought it was going to be an either/orproposition, but I figured out how to keep it compatible with bothversions.

      1. OK… I tried again.
        1. Error when I choose it
        This plugin is marked as not compatible with your actual wordpress version
        2. Error after inline installation

        Warning: require(/vrmd/homepages/u33020/cc/wp-content/plugins/tag_cloud/base.php) [function.require]: failed to open stream: No such file or directory in /vrmd/homepages/u33020/cc/wp-content/plugins/configurable-tag-cloud-widget/tag_cloud/tag_cloud.php on line 16

        Fatal error: require() [function.require]: Failed opening required '/vrmd/homepages/u33020/cc/wp-content/plugins/tag_cloud/base.php' (include_path='.:/vrmd/webserver/php-5.2.8/lib/php') in /vrmd/homepages/u33020/cc/wp-content/plugins/configurable-tag-cloud-widget/tag_cloud/tag_cloud.php on line 16

        what do I do wrong?

  2. Let me also add to my last post that I believe the number of tags in the cloud are somehow related to the length of the page. On a long page it lists all of my tags, on a shorter one is lists less of them, and on an even shorter one it lists even less. All files call the same sidebar.php file so I don't know where they are getting different tag limits.

    If you need to see what I mean, the website is…
    http://avsonline.tv

    The front page does not show the tag cloud (by design) but the other pages (Portfolio, About Us, Press, etc) do show them with each of the pages listed showing less and less tags all the while being limited to 20 in the options.

  3. Hi, I have been using this plugin for a while, and recently upgraded to 5.1. I got stuck in the automatic upgrade problem and then fixed it as instructed. The options didn't seem to be working so I deleted the plugin and then manually uploaded and activated it.

    I can see the cloud on my page, but none of the options seem to be working. For example, it is showing all of my tags even though I have it limited to 20. I have also tried calling in from php in my theme as ctc('number=20') which also does not seem to have any effect. Any Ideas?

  4. Hi all,

    I created a nice little PHP snippet that highlights the chosen tag on an archive-page (without hacking the plugin):

    <code>

    <?php
    $tags = ctc('format=array&smallest=12&largest=36&unit=px&mincolor=#000000&maxcolor=#000000&showcount=no');

    foreach ($tags as $tag) {
    if(is_tag()){
    $pattern = "/".single_tag_title('', false)."/"; // zoekt naar de tag van deze pagina
    if(preg_match($pattern, $tag, $match)){
    $pattern="/color:+.+;/";
    $replacement = "color: #ff0000;";
    $new_tag = preg_replace($pattern, $replacement, $tag);
    $tag = $new_tag;

    }
    }
    echo $tag."
    " ;
    }
    ?>
    </code>

    You can use this snippet in your template inside and outside the loop.

    Have fun with it!

  5. Hi,

    Really like the plugin, but would be great (for me) if there were a couple of other functions:
    1. the ability to output the php function and NOT have the cloud formatting. I just want the tag links without the cloud formating (still be able to output as flat or list).
    2. more output functions, such as most popular tags by date (most popular tags in the last 30 days, for example).
    3. output specific tags using the tag ID number …. that way I can choose a list of 10 tags, for example.

    Thanks again!

  6. Nice update. I had some troule with the autoatic installer but with the comments here that was easy to fix.

    One other small issue:
    I would like the widget to show no title when I don't fill in one. Now it shows the default title ("Tags"). Sometimes I just don't need or want a title above my widget.

  7. Nice update. I had some troule with the autoatic installer but with the comments here that was easy to fix.

    One other small issue:
    I would like the widget to show no title when I don't fill in one. Now it shows the default title ("Tags"). Sometimes I just don't need or want a title above my widget.

  8. There is an issue when you use the automatic update feature. It creates an erroneous folder that contains the actual plugin folder. For the time being, please refrain from using the automatic upgrade. If you have already upgraded via the automatic method and the plugin disappeared from your plugins list, just ftp to your WP install, go into the plugin directory, and move the 'tag_cloud' directory from the 'configurable-tag-cloud-widget' directory to the main plugins directory. After you do this, you can activate the plugin as normal.

    Sorry for the issues…I'm trying to find a fix, and will post agian when I figure it out.

    1. Seems to be another issue as well when using the plugin manually (without widget). < ? php ctc(); ? > No longer works. Is it just me?

  9. Voila.
    I don't know why standart tag cloud widget does not work with Thesis 1.5 theme. So i installed CTC on my webpage. For thesis users you can check out this bug-fix – Agriculture Guide
    Instead of using ( actually can't ) standart tag cloud, you can see how CTC charmed my thesis theme.
    Warmly.

  10. Voila.
    I don't know why standart tag cloud widget does not work with Thesis 1.5 theme. So i installed CTC on my webpage. For thesis users you can check out this bug-fix – Agriculture Guide
    Instead of using ( actually can't ) standart tag cloud, you can see how CTC charmed my thesis theme.
    Warmly. -at the end of the page – i manually inserted the code.

  11. Great.

    Two suggestion.

    1. Widget title should be __('Tags') instead of simply 'Tags'
    2. I'm using Language Switcher, so i've replaced "$tag = str_replace(' ', '&nbsp;', wp_specialchars( $tag ));" with "$tag = apply_filters('the_title', str_replace(' ', '&nbsp;', wp_specialchars( $tag )));". Probably, this could be done in more elegant way, i dont know.

    Thank you!-)

    1. I think it can be done by

      "showcount=yes' option.
      If we can find a way to if loop, if showcount > 1 , then continue.
      Im not professional, but someone who know a bit php can solve this.
      At least i said my opinion.

    2. There is in the new version of the plugin, which was released yesterday. You can limit the cloud with both a minimum number and a maximum number of posts per tag.

  12. Hey Hi, im interested in your plugin, but the download link is broken,
    is there any other place i could donwload it?

    Thanks in advance
    have a nice day

  13. Is there an option to require a minimum number of posts in a tag for it to show up? For example, I want to show 999 tags (all of them) but only if they have 2 or more posts in them. That would be great. Thanks!

  14. Great plugin, but…
    it has a big drawback: a:hover color in the stylesheet for ctc div class does NOt work.
    "text-decoration:underline" for a:hover works perfect, but not the color.
    Would be nice if you could fix it!
    Thanks

  15. I see you deleted my last post. It wasn't spam btw. Not sure why you thought it was. Please email me or check out my website if you have any doubts. Anyway I solved the issue btw. My tags were being displayed by another plugin – I had to edit the part of the plugin that covered the tag cloud from <?php if(function_exists("wp_tag_cloud")) : ?>
    <?php wp_tag_cloud('smallest=12&largest=20&'); ?>
    to
    <?php if(function_exists("ctc")) : ?>
    <?php ctc('smallest=10&largest=28&unit=px'); ?>

  16. I found this plugin via google today and i thought it sounded real good, so I installed it on my test system on my local drive. I activated the plugin and entered in settings, all seemed fine. But it doesn't seem to work, my tag cloud is still the WordPress default. I'm using wordPress 2.7.1 – will it work with this version? Is there anythign I might have missed?

  17. I would prefer to not use the widget section and instead add the correct text directly into the right_sidebar.php file (I have to do this as for some reason widgets refuse to be added to the sidebar #2 (right sidebar) via the widget dashboard. I can use the widget dashboard to add teh ctc widget to the left sidebar but that is not where I want it).

    When I add teh recommended text, nothing happens. I tried adding:

    <?php ctc(); ?>

    to the php file as I had modified everything in the settings area. But nothing showed up. So I modifed the line to this:

    "<?php ('smallest=14&largest=36&unit=px&mincolor=#473C8Bb&maxcolor=#8B2500&format=array&showcats=no&showcount=yes&empty=no&order=DESC'); ?>" But still nothing. I do not think I have a ctc file anywhere.

    When I change it to: ctc<?php widget_ctc(); ?> I do get a tag cloud but alos addional unwanted text. So it is working, just not as I need it to.

    Any suggestions?

  18. I have uploaded the tag-cloud.php to the /wp-content/plugins/ directory. I have activated the CTC plugin. I have modified the various options in the settings section. But when I go to the widgets section to add the CTC widget, I get this error every single time:

    Error 500 – Internal server error
    An internal server error has occured!
    Please try again later.

    Any thoughts?

  19. Hi, I just installed the plugin (by the way, I am new to WP) but wanted to know where in the code I need to set up margins, right now the tags don't break and go to the right beyond my page. Any help is appreciated. Gracias

  20. Hi,
    great plugin simple and exactly what I was looking for 🙂

    In the widget code, I just replace the ' ' between tag name and tag count by &npsp; to keep both on the same line.

    thx

  21. Is it possible to add a feature to sort tags by popularity and then alphabetically?

    e.g. If you have 4 tags and they are labeled as: student, classes, books, courses. Let say you have 10 posts that contain the student tag and the remaining 3 tags both have an equal number of 7 posts.

    The order for most popular would be: student, classes, books and courses.

    The order for most popular sorted alphabetically would be: student, books, classes and courses.

    Currently, Configurable Tag Cloud sorts by most popular, but for tags with the same post count the tags are listed randomly from what I can tell or at the very least they aren't listed alphabetically for tags that contain the same post count.

    In the future, do you think you can implement such features perhaps?

  22. Good to hear! I suggest you update the description of your plugin at http://wordpress.org/extend/plugins/configurable-…to reflect that. It currently (7-Feb-2009) says "Compatible up to: 2.5" and I get a message "Warning: This plugin has not been tested with your current version of WordPress." when I select it for installation on 2.7 (which I will ignore based on your response).

    Thank you for writing this.

    1. I have updated the readme in the WP Extend repository to reflect compatibility up to version 2.8-bleeding-edge (just in case there's anyone running that version in a production environment). I've been meaning to update the readme for a while to reflect current compatibility, and finally made time this morning.

  23. Hi, Great plugin – works like a charm!
    Is it possible to make a dropdown (or have the option for that) instead of a list or flat? how and where can I hack tag-cloud.php to make it possible?

    Thanks!

  24. I would like to exclude certain tags from the sidebar widget cloud display. The 'Tags to Exclude' field does not seem to be working. I'm using CTC 4.5.

    I saw the following so I don't know if this functionality is working yet: "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."

    Thanks. -Ali

  25. I'm not sure why this would be the case. As you can see here, it works as expected with multi-word tags (check the "weight loss" and "sad but true" tags). Do you have a link I can look at to try to figure out what's going on?

  26. Hello! Your plugin is great, but I noticed something strange: when I click a tag with two words nothing is returned. I'm using WordPress 2.6.5 and CTC 4.5. Thanks.

  27. The easiest way would be to use the template tag (<?php ctc('');?>) and make a new page template that you use for the page where youwant the cloud to appear. Otherwise, you could use a plugin thatallows you to use php directly in the page contents, but I've never hadmuch success with that method.

  28. Yeah, you can use it anywhere in your template that you'd like, butyou'll have to use the template tag version instead of the widget.Just put <?php ctc(''); ?> wherever you'd like it to appear, andset the options in the WordPress Admin panel.

  29. AFAIK, there's no reason why you couldn't have two (or more) tag cloudsin your sidebar. You'd just need to use the template tag method (i.e.,add <?php ctc(''); ?> to your sidebar template) instead of thewidget method.As for the filtering, The way the plugin currently operates, it's anall or nothing affair. You might be able to do some filtering usingthe array cloud format, but truthfully, I'm not sure how you'd go aboutdoing it.

Comments are closed.