WordPress MultiTags Plugin

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):
Tags privat and kids

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“.


  1. You need to have at least WordPress 2.8
  2. the usual stuff  (php, mysql, some common sense)


Easy! 🙂

Because I have not (yet) added this plugin to the wordpress-extensions, you have to do the first two steps manually:

  1. Download and unpack the plugin-archive
  2. place the directory „multitags“ under your wordpress-plugin-directory (wp-content/plugins)
  3. login into wordpress as administrator and activate the plugin in the administration-interface
  4. choose the settings (you find the link MultiTags in the settings-menu)
    1. if you want all tags in the title-tag (browser-titlebar) check the checkbox
    2. if you want to insert meta-tags (keywords and description) in your html-head – go ahead, check the checkbox
    3. do me a favour! 🙂
  5. 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):

printf( __( 'Tag Archives: %s', 'twentyten' ), '<span>'
    . single_tag_title( '', false ) . '</span>' );

replace it with

  printf( __( 'Tag Archives: %s', 'twentyten' ), '<span>'
    . (function exists('multi_tags_get_title') ? multi_tags_get_title('and', 'or') . '</span>' ) : single_tag_title( '', false ) . '</span>' ) );

If you want you can also add the tag-description right after that. The complete code looks like this:

printf( __( 'Tag Archives: %s', 'twentyten' ), '<span>'
    . multi_tags_get_title('and', 'or') . '</span>' );
<div><?php if (function_exists('multi_tags_get_description')) 
echo multi_tags_get_description('<p>', '</p>'); ?>


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') ?>

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>')

will produce (line-breaks inserted):




Returns ALL tag-descriptions (only on tag-pages)

echo multi_tags_get_description($beforeDesc = '', $afterDesc = '') ?>
html shown before each description
html shown after each description

Calling multi_tags_get_description in your template tag.php:

<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>

More Problems?

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


Nope! Sorry!
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.
I recommend:

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.
In 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() ));
    $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 );
    $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“

  1. There is no separator between the tag names and the site name in the title being generated…
    I’m getting:
    Site NameTag Tag Tag
    Instead of:
    Site Name – Tag Tag Tag

  2. Hi Martin,

    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?

  3. There is clearly a bundle to identify about this. I think you made various good points in features also.

    1. Hi John,

      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.

    1. Hi,

      what did you exactly try to do?
      If you want to show the tags

      This: <?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.

  4. 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?

  5. 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 again.

  6. 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' );

    Because multi_tags_get_title only 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

Kommentarfunktion geschlossen.

WordPress Cookie Plugin von Real Cookie Banner