Are you using tags in your wordpress-blog? If so, you might already have recognized that you get more traffic by choosing the right tags.
And not only Google is looking for those keywords that you “attach” to your post (iThemes.com points out how important tags are from a SEO perspective. And I quite agree).
It is a good thing for the (human) reader as well.
Simply find all posts that have the tag e.g. “jquery” attached to it. That does make sense especially in this blog, where I have a bunch of different subjects no one is interested in (like stories about my “kids“). At least those who came here with “jquery”-interest won’t bother about my “kids”. “jquery”.
Tags are really useful, when it comes to keyword optimization. Simply tag your posts with the relevant keyword and you got your keyword in the tag-url (as in “http://www.vogel-nest.de/blog/tag/kids“) and usually also in the title of that tag-page and all relevant posts are listed there as well.
Very nice. But wait, we’ll come to keyword phrases as well (e.g. “kids humour” or “wordpress jquery”)
You didn’t find the tag-name in your title? That might be due to your theme not supporting it:
Look in your theme-folder. You should have a file “tag.php” in your theme-directory. The new wordpress-default-theme “twenty-ten” has such a file.
List multiple Tags
Nearly everything regarding tags in wordpress I found in the depth of the internet is only concerned with exactly one tag. But …
Did you know that you could combine multiple tags?
Surely you could attach more than one tag to each post (that’s what tagging is for, right?). But what if you want a “tag”-page that lists all posts that have attached “tag1″ AND “tag2″?
Let’s look at some examples (all examples refer to Piraten Spielzeug).
Maybe you are interested in all products from PLAYMOBIL which has to do with pirates.
You can simply go to:
PLAYMOBIL Piraten (http://www.piratenspielzeug.com/tag/playmobil+piraten)
This lists all posts that are tagged with “PLAYMOBIL” AND “Piraten”.
Now, if you try to see everything tagged with “PLAYMOBIL” and “LEGO”:
you see … NOTHING!
Well, that’s because it doesn’t make much sense. At least I don’t know of any product that’s produced by playmobil and lego and therefore no post has both tags associated. WordPress correctly displays “nothing”.
Maybe you wanted to see all products that are tagged with either “PLAYMOBIL” OR “LEGO”. This can simply be done with:
http://www.piratenspielzeug.com/tag/playmobil,lego (Note the “,”)
That shows a lot more posts
Now you’d expect this to work nicely with your page-title and the first heading (as you could see in the above examples if you clicked the links)?
Have a look at the standard-theme from wordpress (Twenty ten):
For the tags “privat” and “kids” in this blog the page would look like this (without MultiTags Plugin):
Well, ok. WordPress does show the correct list of posts. But …
Whoa! What’s that? Only one (the first) tag “privat” remains in the title and the “archive”-heading.
If you use “kids+privat” (words swapped) only the “kids”-tag (again the first tag) remains in heading and title.
Furthermore, I entered some description-text for each of the tags in the admin-backend for the tags. I’d expect to see those descriptions somewhere on the tag-page. But again … nothing!
If the tag-description is not shown anyhwere, why should I bother entering a description?
And now let’s have a look at the meta-tags for keywords or description! Well, there are …. NONE!?? DAMN!
What if I’d like to do some search-optimization on the keyword phrase “playmobil piraten”? Not only on simple keywords “playmobil” or only on “piraten”! Should I forget about it? Do I have to create a new post and enter the list of posts manually?
Look at Playmobil Piraten (http://www.piratenspielzeug.com/tag/playmobil+piraten)?
Ha! Yes! There it is! The keyphrase is in title, meta-tags and heading-tag.
Who did I do that?
Just use … drum roll … my wordpress-plugin “MultiTags”.
The wordpress plugin “MultiTags”.
- You need to have at least WordPress 2.8
- the usual stuff (php, mysql, some common sense)
Because I have not (yet) added this plugin to the wordpress-extensions, you have to do the first two steps manually:
- Download and unpack the plugin-archive
- place the directory “multitags” under your wordpress-plugin-directory (wp-content/plugins)
- login into wordpress as administrator and activate the plugin in the administration-interface
- choose the settings (you find the link MultiTags in the settings-menu)
- if you want all tags in the title-tag (browser-titlebar) check the checkbox
- if you want to insert meta-tags (keywords and description) in your html-head – go ahead, check the checkbox
- do me a favour!
- if you want to have a correct heading-tag or the tag-description on your tag-page see the examples below (you have to adapt your theme)
To get the correct heading go to the Design>Editor in your wordpress-backend and open the file “tag.php” from your current theme.
Replace the call to
single_tag_title(...) with e.g.
multi_tags_get_title('<h2>', '</h2>', 'and', 'or').
If you use the default-theme TwentyTen find (line breaks for readability):
<h1><?php printf( __( 'Tag Archives: %s', 'twentyten' ), '<span>' . single_tag_title( '', false ) . '</span>' ); ?></h1>
replace it with
<h1><?php printf( __( 'Tag Archives: %s', 'twentyten' ), '<span>' . (function exists('multi_tags_get_title') ? multi_tags_get_title('and', 'or') . '</span>' ) : single_tag_title( '', false ) . '</span>' ) ); ?></h1>
If you want you can also add the tag-description right after that. The complete code looks like this:
<h1><?php printf( __( 'Tag Archives: %s', 'twentyten' ), '<span>' . multi_tags_get_title('and', 'or') . '</span>' ); ?></h1> <div><?php if (function_exists('multi_tags_get_description')) echo multi_tags_get_description('<p>', '</p>'); ?> </div>
The functionality of setting the correct page-title and setting the meta-keywords/descriptions works out-of-the box (nothing more to do than activating the checkboxes in the plugin-admin-interface).
If you want to have access to all the tag-names (or tag-descriptions) on tag-pages you could use the following two convenience-functions.
Returns ALL tag-names (only on tag-pages)
<?php echo multi_tags_get_title($andOp = 'and', $orOp = 'or') ?>
- and-operator – how to name the conjunction in case of “+”
- or-operator – how to name the conjunction in case of “,”
The url for the following example is: http://www.piratenspielzeug.com/tag/playmobil+piraten:
<h2 class="dada"><?php echo multi_tags_get_title('und', 'or') ?> </h2>
will result in:
<h2 class="dada">Playmobil und Piraten</h2>
you might also wish to list tag-names in an ordered-list them as
<ol><li><?php echo multi_tags_get_title('<ol><li>', '</li>', '</li></h2>li>', '</li></h2>li>') ?></li></ol>
will produce (line-breaks inserted):
<ol> <li>Playmobil</li> <li>Piraten</li> </ol>
Returns ALL tag-descriptions (only on tag-pages)
<?php echo multi_tags_get_description($beforeDesc = '', $afterDesc = '') ?>
- html shown before each description
- html shown after each description
multi_tags_get_description in your template
<div class="post"><?php echo multi_tags_get_description('<p>', '</p>'); ?></div>
will result in:
<div class="post"><p>Description of first tag</p> <p>Description of second tag</p></div>
So, now that you are on the road to a tag-expert. Let’s try some advanced stuff.
What if you want to have all posts that are tagged with “pirates” AND (lego or playmobil) (which means: exclude those posts tagged with e.g. pirates and fisherprice, …)?
As we have just learned, you could simply go to the url: http://www.piratenspielzeug.com/tag/piraten+lego,playmobil
That seems way too complicated for wordpress. WordPress doesn’t even list the correct posts when you do that. In fact, I don’t understand at all what wordpress is doing with that kind of query.
Always use only ONE operator (+ or ,) – not both – in the url!
But you can use more than two tags, if it makes sense to you.
Maybe there will be some better support for using more than one operator in the near future.
Since version 0.3 there is a possibility to display a correct rss-feed for multi-tag-pages.
wp-includes/general-template.php (Attention! This is a core-wordpress-file. You should know what you are doing).
Find the lines:
$title = esc_attr(sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $tag->name )); $href = get_tag_feed_link( $tag_id );
and replace them with:
if ( function_exists('multi_tags_get_title') ) $title = esc_attr(sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], multi_tags_get_title() )); else $title = esc_attr(sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $tag->name )); if ( function_exists('multi_tags_get_tag_feed_link') ) $href = multi_tags_get_tag_feed_link( $tag_id ); else $href = get_tag_feed_link( $tag_id );
This is for WordPress 3.0.1. You will loose this change when you upgrade to a new wordpress-version. Sorry! But that change could not be done with a plugin, so I tried to make the changes to core very simply and small.
Many thanks to Frank Bueltge for the feedback and motivation.