The new WordPress UTW gotcha

(Later – Scroll to the end of this post for a small patch to fix the problem with disappearing tags!)

As seen elsewhere and of course on the official blog, WordPress 2.1 was released to much fanfare yesterday.

It works great, I’ve been using the development version on my blogs for quite a while now and until recently it worked swimmingly. It still does, but some time in the last 2 weeks Ultimate Tag Warrior stopped working properly. Whenever someone made a comment on a post the tags on that post would be deleted. It’s gotten so bad now that I’m moderating all comments, and opening those posts in the editor before approving the comments.

A half-way fix is available but moderated comments will still delete the tags so once I verify that the fix does what it does comment moderation will go back to the way it was before.

You should upgrade WP-Cache to the new 2.0.22 release too. It fixed problems I was seeing here with comments and posts not showing up until I deleted the cache manually. Yay!

If you’re interested, a new WordPress MU release will follow in a day or so. More here.

I forgot to mention, do I recommend you upgrade to WordPress 2.1? Yes. If you run a site that is in any way popular your database server will thank you. WordPress uses the MySQL query cache in a much more efficient manner than ever before when reading posts. Make sure your query cache is activated and tweak it until you hit the sweet spot. It’ll make a big difference when your server is under load.

Fix Fix Fix!

HandySolo spotted a simple fix for the tag problem! Check out the thread on this post and scroll to the entry by where he outlines a simple fix for the disappearing tag problem. I just tried it and it works!

Here’s a temporary patch for resetting tags.
Modify ‘ultimate_save_tags()’ function on ‘ultimate-tag-warrior-actions.php’ about line 502:
if (isset($_POST['comment_post_ID'])) return $postID;
if (isset($_POST['not_spam'])) return $postID; // akismet fix
if (isset($_POST["comment"])) return $postID; // moderation.php fix

Even with the fix above, deleting a comment will delete the tags, and sending a trackback/pingback will do the same. fixed that too. You can remove the above fix and apply the following.
Around line 862 of ultimate-tag-warrior-actions.php find the following chunk of code:

// Save changes to tags
add_action('publish_post', array('UltimateTagWarriorActions','ultimate_save_tags'));
add_action('edit_post', array('UltimateTagWarriorActions','ultimate_save_tags'));
add_action('save_post', array('UltimateTagWarriorActions','ultimate_save_tags'));
add_action('wp_insert_post', array('UltimateTagWarriorActions','ultimate_save_tags'));

Replace that code with:

// Save changes to tags
add_action('save_post', array('UltimateTagWarriorActions','ultimate_save_tags'));
if($wp_db_version < 3308 ) { // if lesser than WP 2.0
  add_action('publish_post', array('UltimateTagWarriorActions','ultimate_save_tags'));
  add_action('edit_post', array('UltimateTagWarriorActions','ultimate_save_tags'));
  add_action('wp_insert_post', array('UltimateTagWarriorActions','ultimate_save_tags'));

PS. Stephen Spencer has discovered why UTW doesn’t always work with custom permalinks. This is a longstanding bug, and it’s why I had to use the ?tag= format on my photoblog.

By Donncha

Donncha Ó Caoimh is a software developer at Automattic and WordPress plugin developer. He posts photos at In Photos and can also be found on Google+ and Twitter.

51 replies on “The new WordPress UTW gotcha”

Niklas – more here in a few days time 🙂

michelem – I can use those tags just fine. They’ve been like that for a few years now so I’m quite sure people are used to them by this stage. Are you offering to document the new APIs? The documentation is a volunteer effort and having another hand to help would be great!

HandySolo – That’s unfortunate. All caching problems disappeared when I upgraded. Are you sure you upgraded all files? Or you could downgrade to 2.0.19 again, although that does have a strange ob_flush problem.

If you do downgrade, grab my patch that improves the caching if you’re getting a lot of spam comments (and who isn’t in this day and age?)

Tom – I can replicate the problem by entering a test comment that akismet will catch (using names like “test commenter99” and email address of “” seems to be a good way to make that happen). Once I release the comment from akismet, tags gone. However…

Donncha – Did you see the comment from 082net at the UTW release thread? Adding two lines of code seems to have fixed things.

I hope to hear a final version soon.I had been using this plugin and its really awesome.I need not to say that but my thanks for this plugin u made.

I will keep track of thee post

Thx and Regards

Same here – WP_Cache 2.0.22 didn’t dump the cache on new comments so they didn’t show up. I’m still running an older version for now.

Still going to try WP 2.1 on a couple of my smaller sites – we’ll see how it goes. Hitting the MySQL query cache more often is a great thing!

Hi Donncha, is that fix for UTW working for you well here.

I want to upgrade to 2.1, but just holding it off until I’m sure UTW works. After SK2, this is my most needed plugin.


I have been running UTW (unpatched) with RC2 for a few days without any problems and quite a few comments.

I think I might update UTW with the patch and then upgrade to a final release version of WP

I posted this over on Neato also and wanted to let you know:

The fix by works; however, if you delete the comment that you approved in the first place, the tags somehow get deleted as well.

[…] Acabo de darme cuenta de otro problema de compatibilidad con WordPress 2.1, que afecta a los usuarios del plugin Ultimate Tag Warrior: las etiquetas tan laboriosamente añadidas a una entrada desaparecen si alguien hace un comentario en ella, o si la entrada recibe un trackback o un pingback. El caso está descrito, junto con su solución (casi siempre hay una solución, más o menos elegante), en The new WordPress UTW gotcha. […]

[…] 也许有人已经发现了,当你升到 WordPress 2.1 后,只要有人在你的帖子上留言,或是发 Trackback 或是 Pingback 的时候,帖子的 Tag 就会消失(是被删掉,事实上)。说原因前我先贴一下修补 (via),然后有兴趣的同学再慢慢看原因。 […]

[…] UTW插件的问题: 插件作者在自己的页面上说,已经兼容wp2.1了,发表评论不会再删除文章的tags,但是审核一个评论却会删除。还有其他一些问题,解决起来似乎都很麻烦。作者也没有提出更新的解决方案。还是要再等等看吧。另外还有一两篇文章提到这个问题:, […]

[…] The actual upgrade was performed around the beginning of the fourth week, right where the processor usage went to null. There was some testing done before and after the upgrade along with some fixes to the various plugins that needed optimization and tweaks, especially Ultimate Tag Warrior (which had cause some performance problems and had bugs. Fixed thanks to Donncha’s help). […]

i have another problem with utw, when i try to activate the pluggin, the page goes blank. so i cannot activate it. i never had problems with utw in my last server, now i am migrating everithing and it doesnt work.
what could it be?

Months later I finally get annoyed and check into this! aghhh. I thought I was doing something wrong with my tags and it was a getting confused, but now I know. Thanks Donncha ! 😀

Leave a Reply