WordPress.org

Ready to get started?Download WordPress

Forums

qTranslate
Change meta data for different language FIX (1 post)

  1. magicsun
    Member
    Posted 3 years ago #

    I myself was in need of a fix to change meta data for each language, for the whole site and also using the qTranslate plugin. Since I use this for my personal portfolio site only, I don't need variable meta data for each page, but only for each language.

    If you are also looking for something like this, do the following.

    Add the following code in your header.php (between your head tags). It's a replacement for the excisting meta keywords and description tag.

    <?php
    $lang = qtrans_getLanguage();
    if( $lang == "nl" || $lang == "")
    {
      echo '<meta name="Keywords" content="dutch keywords here" />';
      echo '<meta name="Description" content="dutch description here" />';
    }
    elseif( $lang == "en")
    {
      echo '<meta name="Keywords" content="english keywords here" />';
      echo '<meta name="Description" content="english description here" />';
    }
    ?>

    In my example the dutch and english language is used, but you can change the variables to your own languages. I'm not a php person, I just put together different codes i've found on the web, and it did what it needs to do. (just keep that in mind, lol)

    If you have a more cleaned up version of it, or you see some mistakes, feel free to post them.

    I just thought of sharing it here, since i've spend 3 days searching for it, and maybe someone is in the same situation as I was before =)

    The reason I wanted this is because I often use facebook, and when I plug my site on it, the dutch description kept popping up. I didn't wanted that, because when I post the english version of the site, I want also english text to show. So voila, there ya go.

    Regards,
    Mirna

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

  • RSS feed for this topic
  • Started 3 years ago by magicsun
  • This topic is not a support question
  • WordPress version: 2.8.5