Some fixes and extensions for Wordpress tags such as a tag cloud using only tags found in a specific category and also tag and category intersection.
Download Plugin Now from Wordpress.org!
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).





Awesome plugin, really well done.
Do you think you can add seo-friendly links as well
or can you tell me how to rewrite
“?tdo=tag” to “/tag/”
Would appreciate any help with that!
Oliver
Has anyone found a way to have tdo_tags and query_posts live together? whenever I use query_posts, to sort or control the number of results on a given page… it breaks the ?tdo_tags= call.
thank you very much the code is working perfect i sugest you to add id to you plugin
it has small error i one sign the right code is
$posttags = get_the_tags('');
if ($posttags) {
$num = count($posttags);
foreach((get_the_category()) as $category) {
$cnt = 0;
foreach($posttags as $tag) {
$cnt++;
echo ' slug . ‘” title=”This is single post’.$category->name . ‘, ‘ . $tag->name . ‘”>’ . $tag->name . ‘‘ ;
if($cnt < $num) {
echo “,”;
}
}
}
}
I guess, something like this might do the trick for you pepe:
$posttags = get_the_tags('');
if ($posttags) {
$num = count($posttags);
foreach((get_the_category()) as $category) {
$cnt = 0;
foreach($posttags as $tag) {
$cnt++;
echo ' <a href="'cat_ID . '&tdo_tag=' . $tag->slug . '" title="This is single post'.$category->name . ', ' . $tag->name . '">' . $tag->name . '</a> ' ;
if($cnt < $num) {
echo ",";
}
}
}
}
no the plugin is great, i need to use somthing like this
tdotf_cat_the_tags();becouse i need if a sigle post has tags and you choise one of the tags you have to go in tag page with the tags only from category wich the post is. sorry for my bad english
i found a small solution but a the moment a can’t separate every tag with comma:
$posttags = get_the_tags(''); if ($posttags) { foreach((get_the_category()) as $category) foreach($posttags as $tag) {
echo ' cat_ID . ‘&tdo_tag=’ . $tag->slug . ‘” title=”This is single post’.$category->name . ‘, ‘ . $tag->name . ‘”>’ . $tag->name . ‘ ’ ;} } }the problem is if you put comma all tags look like this: tag1, tag2, tag3,
But I need only: tag1, tag2, tag3
the last tag3 has no comma
any suggestions?
I fixed the problem I was having. I had a custom query_posts
Can you give some hints if your plug-in calls can be wrapped into the query_posts? I want to set up a static page that and at the bottom grab a set of posts in a category filtered by a tag.
Hi pepe, sorry, but the plugin does nothing to
the_tags();template tag. Is there something wrong with it?i mean
? php the_tags () ;
Hi great plugin, but how to correct or use fixes for
This is great