Tag Archives: tagging

wp_tag_cloud() – WordPress 2.3

Small Potato covered one of the new tag functions that will be appearing in WordPress 2.3 – <?php the_tags(); ?>. I was pleased to find, though, that the WordPress development team had included the new tag cloud function, as well, since I currently use UTW’s tag cloud as an enhanced site index.

The documentation on <?php wp_tag_cloud(); ?> is currently incomplete, so I had to do some digging into the core code to find out how to adjust the parameters. <?php wp_tag_cloud(); ?> takes a string of parameters that adjust how your tag cloud displays. For example, <?php wp_tag_cloud('number=20&order=desc'); ?> will display a tag cloud of your top 20 tags and sort them in descending order.

Here are the various settings:

* smallest – Adjusts the size of the smallest tags in the cloud. Default is ‘8’.
* largest – Adjusts the size of the biggest tags in the cloud. Default is ’22’.
* unit – Sets the unit type for font size (i.e. point or em). Default is ‘pt’.
* number – How many tags will display in the cloud. Default is ’45’.
* format – ‘Flat’ displays an inline cloud with each term separated by whitespace. ‘List’ generates an unordered list. ‘Array’ lets you define an array of tags. Default is ‘flat’.
* orderby – Sort the cloud by ‘name’ or ‘count’. Default is ‘name’.
* order – Sort the cloud in ascending or descending order. Default is ‘ASC’.

The new native taxonomy isn’t as powerful as UTW was, but I’m sure it won’t be too long before there will be a host of new plugins to change that.

WordPress 2.3 Beta 2 releases on Monday. I’ll write about any new changes somewhere around then.

WordPress 2.3 Beta 1 Test

I’ve been toying around with the WordPress 2.3 Beta 1 most of the day today. I basically copied this site’s files and database to another location, uploaded the 2.3 files, and ran the upgrade script. Then I spent the next several hours mucking about with the new system. Here’s what I’ve discovered so far:

* The only plugin that ‘broke’ upon re-activation was the Custom Write Panel. And even then, I’m not sure it actually broke. It generates a ‘Plugin could not be activated’ fatal error, yet it clearly showed as active in the list and seems to function just fine when I go to it to write up a new entry. I have a feeling it has to do with the new tag field in the write screen that the Custom Write Panel plugin will obviously not be able to account for properly.
* The UTW tagging conversion process works pretty well. I have a massive database, though, and the tag importer counted just shy of 1200 tags that I’ve used in the past and nearly 4000 tag-to-post relationships. Writing the UTW tags to the new WordPress taxonomy system took awhile, I think in part due to the size of the database as well as to the somewhat sluggish nature of my computer. The conversion appears to have gone off without a hitch, though, and I’ve retired the UTW plugin on the beta test site in favor of the native taxonomy system.
* The categories-to-tags conversion process failed tragically, however. It’s been generating duplicate entry database errors, thus failing to convert category names to tags. Of course, it did, for some reason, single out my Commentary category to convert properly, thus removing every entry from that category (and every other category), effectively removing them from my blog – unless they happened to also be filed under another category, in which case they got to stay. I had similar problems with converting categories to tags with UTW, as well, so it could be something problematic with the whole system. It matters little to me, in the long-run, since I prefer to keep my categories separate from my tags, but since I’m helping to beta-test the software, I wanted to see how badly I could break things.
* The new tagging system has two new functions – <?php the_tags(); ?> and <?php wp_tag_cloud(); ?>. The first takes three parameters and is most useful for displaying your tags at the end of entries. The latter takes a string of options and is most useful for displaying a tag cloud of your specifications in the sidebar, on a page (say, as a site index), or in a post, if you prefer. I’ll talk more about the tag cloud function in the following entry.
* The plugins page in the dashboard also now displays when plugins have new versions (according to the wordpress.org plugins database). It’s a slick little addition that I’m very pleased to see.

By and large I’m happy with the new changes to the WordPress core. I’m eager now to see what sort of new plugins will come out of the new tagging taxonomy.

Tag Filters

I’ve a feature request for all you php ninjas out there, particularly those of you who develop plugins that do strange and wonderful things with tagging:

How about making the ability to tag posts in WordPress a little bit more powerful? For instance, I use “Ultimate Tag Warrior”:http://www.neato.co.nz/ultimate-tag-warrior/ to create a site index here, and it’s nice to be able to click on a particular tag and see all of the entries that fall under it.

Here’s the thing, though – I’d like to see it be possible to filter down still further into those entries. Instead of, for instance, being able to see the entries that fall under speculative fiction only, I’d like to be able to add more tag filters and see all the entries that have been tagged as _both_ speculative fiction and tv shows, or to be able to add still more filters so that I could see all entries that fall under speculative fiction, tv, shows, and heroes, if I wanted to get that specific. It would also be cool to be able to filter by an ‘OR’ command, so that I could sift through all my entries and see all posts that have been tagged as _either_ science fiction _or_ fantasy, for a larger list. I believe that this could easily be done using AJAX to add and remove tags at will. “bbPress”:http://bbpress.org already has something like this in place for individual posts, so I don’t think it would require much effort to modify that script slightly to make it do more and go further.

So, any javascript/php geeks out there looking for a new challenge to expand the functionality of some of useful tools to make them even _more_ useful?