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 6,880 times.
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?
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 1
Any tips?
Have you tried updating the memory allocation? (A quick google will tell you how to do this for PHP)
Queenvictoria posted that comment April 2008, i’m not sure she’s still monitoring the thread. What are you trying to do?
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 ..
Thanks a million for this mate. So useful for my site. Great job!
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?
I answered my own question!
It’s available in the doucumentation.
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
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?
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.
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.
Hi Ira, to confirm if its this plugin, you could simple disable the plugin and see if the tag cloud is correct?
Confirmed. It’s the plugin. The tag cloud (list) wraps correctly when plugin is disabled.
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
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
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.
Please just delete my previous comment, you get the idea. It’s embarrassing how dumb I just was!
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?
Is it possible to go to page 2 or 3 of results when using tdo?
as I seem to get 404 page
thanks
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?
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.
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
Sorry about that!
OMG an error in the noob code
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
Hi, Mark. This is a great plugin, and, as others have said, it’s vital to my site’s design. One problem I’m having is with styling it. Essentially, I want to know what the best way to style it would be.
I see that there is no “stepping” system in place, but instead tag-link-# classes that are related to the tag’s ID. This is really problematic for me, because I need the color of the tag to correlate with its dynamic size, not its static ID.
I’m switching (back) to WP from ExpressionEngine. And basically I need my WP tag cloud to look like what I’ve had in EE. (Example in sidebar here: http://www.leliathomas.com/portfolio)
Is there a way to achieve this with your plugin?
Thanks!
How can I make this work in dropdown tags lists? I don´t want to use tag cloud.
Any fix for this yet?
Is it possible to go to page 2 or 3 of results when using tdo tag?
as I seem to get 404 page
hi, does this work with wp 3.0 ? does not look like that…
Hi @Paul. I haven’t checked yet I’m afraid.
well, it does not in my case… Tag cloud/filtering based on category works, but category/tag intersection does not.
How can I make this work in dropdown tags lists? I don´t want to use tag cloud.
Mike,
Author of Dog Trainer
Hi, I’m using it on 3.0 and everything works fine, the only issue is that the tag title is taking over single_cat_title() and displaying the tag name twice in my theme, check it out: http://pixelmm.com.br/c/portfolio/sites/?tag=internacional
it was supposed to be “Desenvolvimento de Sites” big and “internacional” smaller, both are the tag name
can anyone figure out why?
Great Work… its very much helpful my my site. thanks for sharing with us.
LOVE YOU! You saved my day, this is working just great.
Nice Plugin and i am using it with out any problem. just download from wordpress.org site and install and active.
Thanks for the great plugin. So useful for my site.
Im brasilian, and my english are bad, but…
Thank you.
Hi Mark!
Great plugin! Did you were able to create a 3.0 version? Would be great!
Best regards,
Tom
Thanks Mark for your great plugin.
I have a question:how to show posts randomly?
(when i use query_posts(), the tdo tag fix doesn’t work any more.)
Thanks Mark for your great and helpful plugin.
I have a question:how to show posts randomly:
(when i use query_posts(),tdo tag fix doesn’t work anymore.)
Thanks Mark for your great plugin.
I hava a question:how to show posts randomly?
(when i use query_posts(),tdo tag fixs doesn’t work anymore)
Hi there,
This Plugin is fantastic… thank you so much!
I’m a little new to this, so I apologize if this is a silly question, but is there anyway to separate the tag cloud output with commas?
Thanks!
Hi Mark — not sure if you’re still supporting this plugin, but I had a troubleshooting question.
We’ve got the plugin set up on retroland.com to create archives of tags within a particular category… for example, category “toys,” tag “70s.” The URL looks like this:
http://www.retroland.com/toys/?tdo_tag=70s
It works great on the first page of the results… but on the second and subsequent pages the results are simply the next most recent posts period..
Any ideas? Since the plugin isn’t officially supported to the current version of WordPress, I understand if you’re not interested in supporting it… but if so, do you have suggestions for alternative solutions?
Thanks very much,
Matt
I really like this plugin since it does what it is meant to do in an easy way.
Yet I have one request, that others already asked: Is it possible to display the tag list (or cloud) as a dropdown? As a bonus it would be great to show the number tags right next to each tag.
need to check on this how to integrate on a wordpress + classipress theme site.
Hi. tHanks for you plugin, it work well.
however i’m looking for a way to display th number of post linked to a tag in a category page.
I try with ‘format=array’
but in my llop, i can’t acces to “$tag->count”
Can you please helpe me ?
thanks
Hellooooo,
This plugin is very old BUT I installed it with WordPress 3.6.1 and it works like a charm! I’ve just started with it but I’m one happy puppy.