Downloads: TDO Tag Fixes Wordpress Plugin (0.5)
Download now from Wordpress.org!
Requires at least Wordpress v2.3 and tested up to Wordpress v2.5.1.
This plugin is simply intended as an example of how to implement tag and category intersections. However it has got a bit more feature-heavy recently. Please feel free to re-use the code in your plugin. This plugin is based on information found here.
Version 0.5 enables true 'or' tag intersection when using a category. It wasn't working prior to this (and no-one noticed). Thanks to Joel Giddey for spotting it.
Wordpress 2.3 introduced native tagging support, which is rather nifty.
But did you know that you can display multiple tags in the one archive and even generate a feed for that?
- "
http://your-blog-uri/?tag=tag1,tag2" this would get all the posts tagged with tag1 or tag2. - "
http://your-blog-uri/?tag=tag1+tag2" this would get all the posts tagged with tag1 and tag2 - "
http://your-blog-uri/?tag=tag1,tag2&feed=rss" this would get you an RSS feed for all the posts tagged with tag1 or tag2
Neat huh? But did you notice that on the generated tag page you see only one tag listed in the header? This function fixes that and displays all tags used to generate that tag archive. It does this by silently modifying the single_tag_title template tag. It'll even work on the RSS feed generated by that page!
What would be also be cool is to be able to intersect categories and tags so you could grab posts with tags from a specific category for example?
With this plugin you can. It's not perfect however. It only allows intersection between a single category and one or more tags. Technically Wordpress should be able to support multiple categories and tags intersections but it didn't work for me in Wordpress 2.3.x and 2.5.
So go to one of your category pages. If your using using fancy permalinks then at the end of the url add "?tdo_tag=a_tag". If your not using permalinks then you can just use "&tdo_tag=a_tag". You must use the tag slug, not the full tag name. You can use multiple tags as above using "," and "+".
- Example not using fancy permalinks: "
http://your-blog-uri/?cat=35&tdo_tag=tag1,tag2" this would get all posts in category with id 35 and tagged with either tag1 or tag2. - Example using fancy permalinks: "
http://your-blog-uri/category/mycategory/?tdo_tag=tag1+tag2" this would get all posts in the category "mycategory" and tagged with both tag1 and tag2.
This plugin uses this intersection code to automatically modify the built-in tag cloud template tag wp_tag_cloud so that if it is used on a category archive, it shows only the tags within that category. You can then click on a tag in that tag cloud and it will get the posts for in that category that tagged with that tag. (You can disable this and just use the specific template as you need).
This plugin has been downloaded 1,265 times.
Guest
March 2nd, 2009 at 3:35 pm
Hey ,
I love the plugin. But I still can’t figure it out with single pages. I’ve updated the code like Queenvictoria descriped, still no results.
Can you please upload a new php file with the correct update?
Guest
March 12th, 2009 at 2:38 pm
Hey, the tag cloud breaks for me when I enable this plugin:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 7680 bytes) in /home/xxx/xxx/wp-includes/kses.php(1005) : runtime-created function on line 1Any tips?
Administrator
March 13th, 2009 at 5:41 pm
Have you tried updating the memory allocation? (A quick google will tell you how to do this for PHP)
Administrator
March 13th, 2009 at 5:43 pm
Queenvictoria posted that comment April 2008, i’m not sure she’s still monitoring the thread. What are you trying to do?
Guest
April 9th, 2009 at 1:55 pm
hi Mark – thanks for the great plugin. Can you give me some clues for modifying it to also display the post count for each tag in the tag-cloud please ? I’m not a programmer, obviously ..
Guest
April 17th, 2009 at 5:30 pm
Thanks a million for this mate. So useful for my site. Great job!
Guest
June 5th, 2009 at 1:47 am
Could we have a filter that also overrides the current tags on a post so that it uses TDO Tag Fixes’ URLs.
eg. I have a post and inside that post there are links to tags assigned to that post.
I want these tags’ links to be like:
http://website.com/category/mycategory/?tdo_tag=tag1+tag2
Is this possible?
Guest
June 5th, 2009 at 1:51 am
I answered my own question!
It’s available in the doucumentation.
Guest
June 8th, 2009 at 6:29 pm
Hey there!
Love the plugin–thanks for your help. I’m not sure what happened today, but I started getting an error:
Catchable fatal error: Object of class stdClass could not be converted to string in /home/madefoum/public_html/kidcityny/blog/wp-content/plugins/tdo-tag-fixes/tdotf.php on line 230
Can you help at all please? Much appreciated!
-N
Guest
June 11th, 2009 at 1:46 pm
Great plugin, I have been using it on a project in development and will go live with it.
Taxonomy has been added to wp_tag_cloud in Wordpress 2.8. Wondering if it will effect this plugin at all?
Administrator
June 11th, 2009 at 2:21 pm
Ah sugar. I had forgotten about this plugin and Wordpress 2.8. Right now, I don’t know, I don’t think it should break the plugin, but I’m not 100% sure of this.
Guest
June 30th, 2009 at 10:06 am
Hey Mark. Your plugin is crucially important for the proper layout of my site
I am deeply grateful to you for taking the time to code this extremely useful plugin. I had one small question — on my homepage, which is the one page on my site that is not category specific, the tags wrap very nicely. On category pages, however, where your plugin is activated, the tags don’t wrap and consequently get cut off. (I have tags set to list mode, not cloud mode).
I figured it must be related to your plugin, since the plugins wrap on the home page that includes all categories.
Administrator
June 30th, 2009 at 10:44 am
Hi Ira, to confirm if its this plugin, you could simple disable the plugin and see if the tag cloud is correct?
Guest
June 30th, 2009 at 4:13 pm
Confirmed. It’s the plugin. The tag cloud (list) wraps correctly when plugin is disabled.
Guest
July 1st, 2009 at 12:45 pm
Hi Mark. I think I’ve narrowed down the problem a bit. Perhaps now you could suggest a solution. It seems that when the plugin is activated, tags with spaces are created in the with   and not spaces. This makes it impossible to wrap them. Example:
With Plugin:
Weak Economy
Without Plugin:
Weak Economy
Any ideas of how to fix this?
Thanks again!
Ira
Guest
July 1st, 2009 at 12:56 pm
Hi Mark. I think I’ve narrowed down the problem a bit. Perhaps now you could suggest a solution. It seems that when the plugin is activated, tags with spaces are created in the with   and not spaces. This makes it impossible to wrap them. Example:
With Plugin:
Weak& nbsp;Economy
Without Plugin:
Weak Economy
(strategic spaces added to show code)
Any ideas of how to fix this?
Thanks again!
Ira
Guest
July 1st, 2009 at 1:43 pm
Ok, so I found the following line of code and decided to comment it and see what happens:
$tag = str_replace(’ ‘, ‘ ’, wp_specialchars( $tag ));
So far, my problem has been resolved. My multiple word tags correctly wrap. But did I just set off global thermonuclear war somewhere else by doing this? I’m assuming there’s some reason for that line of code?