Not so ultimate WordPress 2.2 tags

Update: I forgot to mention that you must hack a core file and adapt your theme, too. See the end of the article.

Upgrading to WordPress 2.2 bleeding edge is an adventure, always. Not necessarily because they introduce new bugs–it’s the new features that are sometimes worrying. When one svn up changed all the feeds from somewhat-valid RSS to invalid Atom, I didn’t complain because, hey, it’s the bleeding edge, and Atom is so much better anyway. I just fixed the bug, and it was good. (In retrospect, I should have sent a patch. I forgot.)

Having tagging functionality in the WordPress core is a good idea, too. In general. Basically. However, if there already exists a widely-deployed tagging plugin–and for WordPress, one very much does exist–it may be a good idea to look at the functionality and semantics of the existing plugin before reinventing the wheel, badly.

UTW has a function named is_tag(). WordPress 2.2 adds a function of the same name. Ergo, things break. Renaming the plugin dir helps, but your tags are gone. Re-activating the plugin shows you the shiny new plugin sandboxing (which, btw, Habari started in January), but doesn’t bring you back your tags.

Some searching might point you to the UTW tags importer (Options > Import > UTW). After a funny message about deleting unwanted tags from the UTW management page (hey, no plugin, no options page, okay?), the import kinda works. The “Did we say 5 steps? We meant 4. Ha ha ha.” joke is getting pretty old pretty fast, though. Then, instead of the UTW_ShowTagsForCurrentPost() function, you use the_tags() in your template. Of course, the semantics of the_tags() are slightly different from those of the_category(), and completely unlike the old UTW functions semantics.

So I decided to get UTW back. Despite claims to the opposite, the changes required are actually pretty simple: open ultimate-tag-warrior.php and search for occurrences of is_tag(. Replace all occurrences with UTW_is_tag(. Activate the plug-in.

Update: Do the same in your theme – where you use is_tag() now, change it to UTW_is_tag(). Then, open wp-includes/rewrite.php, search for the function get_tag_permastruct, and add return false; directly after the opening brace. (This unbreaks /tag/ pages.)

Done.

45 Replies to “Not so ultimate WordPress 2.2 tags”

  1. I had the same problem initially, but I did get UTW working again on SVN Rev. 5213, without any hacking of core UTW or WordPress files.

    Still, I do want to switch over. Why haven’t I already?

  2. Revision 5227 broke UTW (and thus, my site) for me. Prefixing all of UTW’s functions is a good idea either way, I think.

  3. 5227? Thats my Norwegian Post Number. 🙂

    Mine broke earlier than that, but was again fixed in 5213. Of course prefixing UTW is a good idea, but given the current state if UTW and WP the best idea would have been for WP to not stomp it’s feet on top of the existing UTW plugin, as you said above.

  4. A couple of questions, since you are obviously aware of how tagging works in 2.2, and I am a confirmed UTW user.

    1. Was it easy to switch WP tagging off neatly when you switched back to UTW?

    2. Does WP tagging create tag clouds or do we need a plug-in for that – hohoho ?

  5. I actually have both enabled now, as far as I can tell the WP tags doesn’t really do any technorati integration (i might be wrong though), so I just told UTW to process the tags but not display them in my theme.

    I have not seen a built-in tagcloud in the WP tags.

  6. As far as I could see in my quick run through the code, the wp tagging system does not do any integration or tag clouds. OTOH, if you don’t change your theme or just remove the call to the_tags() from your theme, the wp tagging functionality doesn’t interfere with anything. It might show up in feeds, but I haven’t checked.

    I’m back to using exclusively UTW, for the tag clouds, the better UI, and the legacy data.

  7. I know, I mentioned it in the article, but I prefer UTW at least until the WP tagging stuff is mature.

  8. Okay, thanks. I will make the changes to UTW now – before I upgrade – and I think I will join you in using UTW until WP provides a reason not to.

    Which would have to include a quick, easy and foolproof way of gathering up the legacy tags and entering them into the new system.

    BTW, if the built-in tag system really does mean we are going to see plug-ins for technorati integration, tag clouds, and so on, then I think it is not really a step forward at all.

  9. Owen, there is an importer for UTW’s tags under Options > Import > Ultimate Tag Warrior. However, with no way to get related posts, related tags, a tag cloud etc., the point is moot for me 🙂

  10. I’m using SVN r5288. I followed your changes, i.e. change all occurrence of is_tag( to UTW_is_tag( in ultimate-tag-warrior.php. And change the permalink structure of tag to other format to ensure not to conflict with UTW tag search URL.

    Tag search (both /tag/tagname or /index.php?tag=tagname) is still can’t work properly.

  11. You have to use UTW_is_tag() in the theme, too, where you currently use is_tag. Sorry, I should’ve made that clear. I’ll update the post.

  12. I followed your guide after upgrading to WP 2.2 and UTW now works flawlessly in my blog. Thanks a lot 😀

    Just a quick note, I also need to modify is_tag() funtion in ‘ultimate-tag-warrior-actions.php’

  13. I wonder what else may be conflicting. I’ve made the UTW_is_tag() mods, but there is a problem with basic WordPress search.

    I can search all posts it seems which were written before the 2.2 upgrade. None written after show up.

    I looked at the posts in the database, and can’t see anything unusual in the fields of any of the later ones which aren’t searched.

    There’s a similar problem of not searching successfully on pages, enabled by the Search Everything plugin.

    All goes back to working normally if I disable UTW in Plugins.

    Any ideas?

  14. I guess I’d better say that I didn’t find any get_tag_permastruct() in rewrite.php, or anywhere else, to follow your short-sheeting return instruction.

    Did you mean some other function name (there are lots of get_xxx_permastruct) to modify, and could that have to do with the search fail on new posts problem?

    Also will say for the record that I deactivated all plugins except UTW, for a final check that was what causes the search fault.

    Regards,
    N.

  15. Ok, I have found the fix for this problem. It’s in the comments on this page:

    http://www.neato.co.nz/forum/comments.php?DiscussionID=1560&page=1#Item_0

    The fix is in ultimate-tag-warrior-actions.php. I’d take a safe copy before proceeding. Line numbers also change. Search for the $join and you’ll find it in two places. The right place is the second place.

    There are more issues with UTW and WP2.2, but this will get your searches properly working – and it is a need for earlier versions of WP also. So maybe this plus the funny issues is what’s keeping the Neato forum silent.

  16. well everybody is shouting about the IMPORT option. damn, i have a german version. and there is no such an option or i’m just to stupid to find it. that’s offical wordpress 2.2. can someone send an URL of the import option please? help me please i need to import the tags. the version i’m using is 3.14159265.

  17. oh that’s great news. höhö. hust hust. well, then maybe I need to update the function calls only with the latest versionl. but stop, achtung halt! why does my old plugin version with my old database date which was fine for WP 2.05 then re-incarneted with a WP 2.2 codebase and using a simple wp-admin/update.php scriptrun (which works) does not work after.all? if so WP 2.2 has no tags at all??? why does UTW does not work any longer? the old version as well as the new? any help?

    I will now replace the function calls to the new UTW_ naming. hope this helps but I bet it won’t and all this is broken.

  18. okay it seems that UTW is just crashed with WP 2.2. punkt. hopefully one of both sides will win – the plugin or wp core. I really liked UTW.

  19. There is an easier way. Just call “is_utwtag()” which is built into pi+ versions of UTW. If is_tag() exists, UTW will use is_utwtag(). If not, both is_tag() and is_utwtag() works.

  20. Hi there, was trying to activate the plugin… clean installation, no other plugins installed… wordpress 2.2 – it triggered a fatal error and won’t activate…

    I read the code a bit…

    if(!function_exists(‘is_tag’)) {
    function is_tag() {
    return is_utwtag();
    }
    }

    shouldn’t this sandbox is_tag and make it safe?
    any chance to get some logs out of wordpress… where? php logs won’t help 🙁

    I didn’t insert anything in the theme… so I guess it should be safe

    anyone experiencing the same problem?

    cheers

  21. I tried to follow your instructions, but I can’t find any .php files in my theme which use is_tag. The theme is Cutline – if anyone is familiar with it then I would appreciate advice. My wp-includes/rewrite.php also does not have the function get_tag_permastruct.

    In the end, I went to the UTW options and deactivated ‘use URL rewriting’. It seems to work now with no other changes, but of course tag page URLs now end index.php?tag=sometag. I’m not sure whether that matters, but at least the tags are no longer leading to 404s.

  22. same problem here – followed the instructions but some of the code snippets referenced don’t exist – hope someone writes a fix for those of us still having this problem

  23. tagging wasn’t added in 2.2 official release. if it was i don’t see an option for it.

  24. I also deactivated ‘use URL rewriting’. The problem I have is that all of my pages with the old tag url are showing in google and lead to a 404 page.

  25. Ok, I’ve figured out a very simple solution to fix it all.

    Go to ‘permalinks’ in the options menu and ‘update permalink structure’. That will fix the problems and you won’t have any other issues. Basically you can go back to using URL rewrite and no more 404s 🙂

  26. Thanks Michael – I hadn’t realised that the old tags would lead to 404s (I’m a bit of a WP newbie). I’ve just done what you suggested and now it seems to be working perfectly, with the URL rewriting on. I also don’t get 404s from the non-rewritten (i.e. index.php?tag=) URLs, so all seems to be good.

  27. John

    I’ve just tried to post a comment on your blog and the comment form takes me through to a duplicate post, its an error of some kind, you might want to take a look.

  28. Michael

    The comment did come through – I have just approved it and will reply to it on my own blog. I’ll look into the error message, as it doesn’t inspire much confidence. I’m not entirely surprised – updating to 2.2 broke several things (such as the content form, which also seems to clash with UTW). It was my first WP update, so I suppose I’ll have to get used to it.

  29. whoa WAIT – people, don’t miss michael’s post above – if url rewriting isn’t working for you, turn it back on and then go to options > permalinks and hit the ‘update permalink structure’ – it works! Not sure if there is something suboptimal about doing it this way, but at least my /tag/ urls work again – still will be nice when utw is updated to work with wordpress 2.2x, but making that change does seem to fix things well enough …

  30. maybe someone pointed it out somewhere, anyway, it seems UTW is not working with tags which consist in more than one word.
    It always leads to NOT FOUND page.
    i saw it happening in mine and in other blogs.
    everything works fine when u check single words

    how to fix this?

  31. then i really don’t know what to do, i changed template to check if that was the problem, i changed permalink, used normal url, nothing changed, with more than one word it’s not working.
    any idea of what i could try more?

    thanks

  32. i got it working
    after millions attempts
    in case someone is wondering how to do, i just pressed the TIDY button

  33. Hi, I have the same problem, I’m using WP 2.2.1 and UTW 3.14. Apparently you found a way to make UTW work properly with WP 2.2.1 but I’ve seen other solutions and I wonder which one is the more appropriate. Maybe you can help me to find out, I don’t know any PHP so I’m lost, I want to hack as less as it’s possible. Any help is welcome 🙂

    Here are the other solutions besides yours, dunno if they’re working tho:

    http://quark.qpsmod.net/coding/ultimate-tag-warrior-fix-for-wordpress-221
    http://www.neato.co.nz/forum/comments.php?DiscussionID=1560&page=1#Item_0

  34. Hi,
    I’m using wordpress multi user instead of basic wordpress for all my blogs. This way I can easily add and mainting subblogs. Yesterday I’ve downloaded the last stable version of wordpress mu (wordpress-mu-1.2.3) which is based on WordPress 2.2.1. I had the same problem while activating UTW (fatal error), I tried the changes you mentioned above, but nothing changed for me.
    If any of you find a fix for mu, I really appreciate if you share it here.

    Thanks in advance.

Comments are closed.