Alternative Way To Use WordPress Tags

WordPress tags, as you know, are usually used for adding specific labels to posts.

This basic usage is useful in some cases for example when you want to generate a navigation section for your blog based on a tag cloud. In my opinion, this kind of use of tags as simple descriptive labels is now obsolete: tag clouds are almost dead and there is no reason to continue to use them. So you can image to use WordPress tags in a different way to implement WordPress themes with complex behaviors based on tags. An interesting example is to use WordPress tags to provide a multi-language version of your posts. The only thing you have to do is to create a new post that contains a translated version of an article already published in your main language and add a tag describing the language of the translated post (in the following example I used “italian”).

Now, in the original post, add a custom field to create a link to the translated post (in this example I called the field “italian”). Than add this code (for example in single.php) to display the link to the translated post on your template:

<?php if (get_post_meta($post->ID, 'italian', true)){?>
<a href="<?php echo get_post_meta($post->ID, 'italian', true) ?>">Italian Version</a>
<?php } ?>

You can exclude all posts that aren’t in your main language from index.php, category.php, tag.php, search.php and so on, simply changing the basic WordPress Loop with the following code:

<?php
$paged = (get_query_var("paged")) ? get_query_var("paged") : 1;
$args =array(
"tag__not_in" => array('ID_TAG'),
"paged"=>$paged,
);
query_posts($args);
if (have_posts()) : while (have_posts()) : the_post();?>

where ''ID_TAG" contained into "tag__not_in" => array('ID_TAG'), represent the ID of the tag you want to exclude from the loop.

If you have other ideas, share your suggestions with a comment.

  • Ashfame

    I would suggest using Custom taxonomies for such a purpose.

  • Michael

    I already use costum fields with referending page id for teaser on a front page (teaser for pages). You can nearly do everything with wordpress, amazing! In fact with the new possibilities sinde version 3.0.

  • justin

    interesting idea. i wonder if something like this could work for Ning networks. any ideas about how one might accomplish this using ning tags?

  • inerds

    Good idea Antonio,

    I have been using tags to specify the location of the post on the front page, like in a news site, which posts to be listed on the top left div box.

  • Amitash

    Interesting and very useful for multilingual sites. Antonio, I saw some italian language in facebook as well on your profile! I could not understand though :D

  • bfred.it

    How about WPML and xTranslate? I’ve been trying the latter and it seems to work fairly well (better than WPML)

  • Edy Pang

    Brilliant idea. I was trying some plugin to do this, but with this method I think I can stop considering the most suitable plugin because it’ll be good enough. Great, thanks Antonio.

  • Jey keu

    “Custom Fields” are actually for situations like this

  • Ed

    Great post! – Life saver, was searching high and low for a solution like this.