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.
23 Kommentare zu „WordPress MultiTags Plugin“
There is no separator between the tag names and the site name in the title being generated…
Site NameTag Tag Tag
Site Name – Tag Tag Tag
Can you help?
thanks for your comment.
Hm, this plugin doesn’t mess around much with the general title.
Do you have this problem only on „multi“-tag-pages?
What are your settings for „blogtitle“ in „settings>general“?
The module simply returns a new „title“ for multi-tag-pages. The rest of the title (the blogname) including the separator should be added by wordpress.
Have you got a custom theme?
I hope you also create the plugin for multi categories. 🙂
hmmm no I haven’t looked into this. Categories seem to be so old-fashioned 😉
I like your blog. Really helpful and very motivational. Thanks a lot. This will help me a lot.
There is clearly a bundle to identify about this. I think you made various good points in features also.
Awesome little plugin to clean up WPs rough edges, thanks!
thanks for your feedback.
Very much appreciated.
Awesome wp plugin, thanks!
that’s nice. Thanks for your feedback.
As I noted on: WordPress.org a bug was introduced in WP 3.1.1
This is already registered in Trac and hopefully will be fixed in 3.1.2
So let’s hope for the best. After the release of WP 3.1.2 I will release the next version 0.4 of this plugin.
i tried to display tags on sidebar by calling but it’s didn’t appear anything…could i insert it manually
what did you exactly try to do?
If you want to show the tags
<?php echo multi_tags_get_title( 'and', 'or' ) ?>
should work. In a sidebar-widget you need to have the „Exec PHP“-Plugin installed, because else no php would be executed in a text-widget.
sorry, for missing code for my first comment i meant i was called tag using but nothing tags appear on my sidebar. i don’t use widget in my sidebar..how multitags works to generate tag could you help me to explain?
Could this plugin works like http://diy.stackexchange.com/questions/tagged/electrical and when i clicked on related tags ex:wiring query result /electrical+wiring and displaying ‚wiring’tag on all the posts found…i hope you can understand what i wrote cause my English is horrible
sorry, this plugin does not generate a tag cloud.
The Tag-Cloud-Widget is a standard-widget from wordpress. It will display nothing if you haven’t assigned any tags to any posts.
This plugin is not supposed to generate tag clouds, sorry.
The „Related Tags“ you mentioned are very cool. I always searched for that kind of plugin.
Maybe this one does the job:
thanks for your kindness to explain very clearly 🙂
Thanks for this plugin whichs is a must-have for SEO!
Thank you. You are so right 🙂
Wow! Really Great Plugins. Thanks a lot for sharing it!
Thanks for your comment and I hope this plugin is useful for you.
Hello, thanks, it’s great great great for seo.
I’m on wp3.5
I use your plugin with « Sk Multi Tag », the perfect combinaison.
but, (there’s always a but)
I have a bug for the header page title.
// set page-head-title
public function title($title)….
dont work, WP display only the first tag.
If before or after wp_title( ‚ | ‚, true, ‚right‘ ); I put your function it’s display nothing, but if I use <?php printf( __( '%s', 'twentyten' ), '‘
. multi_tags_get_title(‚and‘, ‚or‘) . “ ); ?>
it do something like that :
tag1 and tag2 sitename
and i cant replace by “ | “ because it dont work anymore
echo multi_tags_get_title(‚and‘, ‚or‘);
dont work to….
have you some solution ?
Thanks wdz for your comment.
I just checked my plugin with WordPress 3.5 and it works fine.
Maybe I don’t quite understand.
If you want to have the „tags“ displayed before the title you go to your header.php and do something like this:
echo multi_tags_get_title('and', 'or');
wp_title( '|', true, 'right' );
multi_tags_get_titleonly returns (but does not print or echo) the text.
If you want to use another separator in your title, you can use
wp_title('-', true, 'right')
But you carefully read: http://codex.wordpress.org/Function_Reference/wp_title