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,967 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 12:57 pm
In my previous comment, I added spaces before the and tags, and in the preview, it showed the line of code, but when I submitted it, it converted the tags anyway. Sorry about that. But anyway, you can see that it added the nbsp.
Guest
July 1st, 2009 at 12:59 pm
Please just delete my previous comment, you get the idea. It’s embarrassing how dumb I just was!
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?
Guest
September 16th, 2009 at 12:15 pm
Is it possible to go to page 2 or 3 of results when using tdo?
as I seem to get 404 page
thanks
Guest
October 11th, 2009 at 4:55 am
I’m looking to replace the the_tags so that the displayed tags link to a result of posts related to that tag and under the category of that post. But replacing the the_tags with todotf_the_tags doesn’t work. Am I missing something? Would you be able to show an example code line of how you did it?
Guest
October 21st, 2009 at 8:05 pm
Hi! Thanks for the great plugin. I’m having trouble with implementation however. It works fine when I query /?mytags=tag directly in blog root. However, my category php pages are all custom queries, so typing /category/mycat/?mytags=tag pretty much does nothing.
Is there any way to force wordpress to use, say, an archive.php file for displaying anything that has to do with the tags? Or can I force it to use search results pages to display if I add something like ?s=0 in the url?
I desperately need this working!
Thank you.
Guest
November 12th, 2009 at 9:57 am
Thank you Mark for all your efforts, you’re the bestes ever!
It’s seems hard finding a working plugin to display only “one category” tag cloud with wp 2.8?
Your piece of code is the closet I’ve come to a solution. It works for the tag cloud filtering and correctly only displays one category tag cloud, (I could never ever have done that myself) and the code works for the href URL upon a click on a tag. But the actual click only takes me to a category page, with all post within that category(?). So I solved it with an ugly hack. I read the query string at the category page and filter the category page with the tag_parameter in the query_post.
Voila! I got a working Mark cunningham plugin!
And I know almost none PHP
/Linus
Guest
November 12th, 2009 at 10:12 am
Sorry about that!
OMG an error in the noob code
Guest
January 7th, 2010 at 5:09 am
Hi man, your plugin is very good. But, i need change the separator in wp_tag_cloud. I have this in my theme:
When the plugin is activated i have a trouble:
Array
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\wp\wp-content\themes\gluttony\category.php on line 19
Solution?
Thanks