Downloads: TDO Tag Fixes Wordpress Plugin (0.5)
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).
Guest
November 11th, 2008 at 7:58 am
Hi Mark
Problem solved. There was a problem with the tdotf_the_tags when used on category pages. Thanks to the comment by QueenVictoria (#comment-103241) I was able to solve the problem.
In the tdotf.php file, I replaced the code beginning on line 399:
function tdotf_the_tags( $before = ”, $sep = ”, $after = ” ) {
global $tdotf_tag_get_var,$cat;
if(is_category() && isset($tdotf_tag_get_var)) {
$tags = get_the_tags();
with the following:
function tdotf_the_tags( $before = ”, $sep = ”, $after = ” ) {
global $tdotf_tag_get_var,$cat;
if ( ! $cat ) {
$category = get_the_category();
$cat = $category[0]->cat_ID;
}
if(isset($cat) && isset($tdotf_tag_get_var)) {
$tags = get_the_tags();
and this did the trick.
One thing to note is that tdotf_the_tags was misspelled in the original file (as tdof_the_tags). I suppose either spelling would work, but I changed it to tdotf_the_tags for consistency.
-Mark
Guest
November 10th, 2008 at 4:51 pm
Sorry, it was basically an IF statement using is_category. If it is_category, then show the banner. That works for me - if it is a certain city, then show a certain banner. However, I’m trying to make an IF statement for a certain city and industry (intersection of a category and tag) and only show the content then. Does that make sense?
Guest
November 10th, 2008 at 4:38 pm
Is there a way to create a custom template page for when people are on an intersect page for a category+tag, i.e
category+tagname.php?
Administrator
November 10th, 2008 at 10:59 am
Bjorn, your code seems to have been stripped out of your comment. Any chance you could try posting it again, but with the < and > replaced with < and >? (it’s the angle brackets and “php” references that get the code stripped out)
Administrator
November 10th, 2008 at 10:56 am
I’ll have to have a look at it, when I get the chance. I haven’t extensivily tested that part yet.
Guest
November 10th, 2008 at 4:55 am
Hey there! Great plug-in. This solved my problem for a website that lists industries (tags) in cities (categories). I’m now able to go into a city and list a tag cloud of all the industries in that city. You can see yourself at Studentrabatt.no (a Norwegian website that lists all the student discounts in Norway).
I have a question. On the city (category page), I have some banners in the right margin. I’d like to offer different banners for different cities, which is solved by the following code:
However, when I drill into an industry from there (tag), I’d like to show a different banner ad. I’m looking for some code that does something like “if this category AND this tag then echo Banner ad 2″.
The goal is to offer very specific ads to companies in certain industries for certain cities.
Is this possible currently? If not, would it be a lot of development, and do you know of anybody who’d be interested in helping out? (hint hint :-)…