v How to make a multilingual website on WordPress | Luigi Nervo

Sito web multilingua con WordPressMore and more customers are asking for a multilingual website to intercept foreign markets. How to do on WordPress? The solution is the free plugin qTranslate, but it is not enough just install it: you need to build an efficient structure, to set the qTranslate parameters, to add extensions and fix something in the code. Thre are not simple operations are required a deep knowledge about WordPress and some basics of Php language; but, once settled, qTranslate plugin is very effective and easy to use. Below I will write step by step how to make a multi-language website on WordPress, using the example of a blog both in Italian and English. The first question is: I have to set two installations of WordPress or I have to create the multilingual site in one installation? They are both possible paths. If we want to create two different websites, one for every language and independent of each other, the best solution is that of the two installations. But, if we want to create a double site in two languages with the same pages and the same items, with double installation we would waste so much time in the construction phase and in the content management. In this case, the best solution is to connect all the languages in iìone website and organize contents through a plugin like qTranslate

It is best to use a subdomain or a directory system for a multilingual site? In other words: en.website.com or website.com/en? There are great differences between the two options and both are used by Google Webmaster Tools for geotargeting. The subdomain is slightly more effective for search engines because it allows different positions of the server, and then it divides more sharply the languages. However, the directory structure is perceived better by the user and it is easier to manage. Evaluating the pros and cons of the two options, the second is the recommended one. We chose the domain.

Now we can install the plugin qTranslate for WordPress and discover the basic functionality. You can install a widget that allows you to insert the flags within the site to read the contents in all languages selected (we can add all the languages that we want, even invented ones). By an intuitive interface of the editor of posts and pages, we can set the title and the body text in the languages chosen. We can also change title, description and keywords in the fields of the plugin All in one Seo, or category names and titles of the widgets by inserting before the text the codes associated with the languages, for example [: it] and [: en] But this system is not enough.

WordPress multilingue

How to translate parts of code or text widget with qTranslate? First of all, you have to install the plugin qTranslate Extension and to replace rows from 202 to 210 of its php file with the Java code that follows.

jQuery(document.body).bind('click.widgets-toggle', function(e){
     var target = jQuery(e.target);
     if ( target.hasClass('widget-control-save') ) {
          var form = target.parents('form:first');

In this way we solve the problem of the text widget that now understands the language codes. To work on the code of the pages you have to copy php commands like the following.

<!--?php if(qtrans_getLanguage() == "en") : ?-->English text<!--?php endif ?-->

Obviously, you should replace en with your language codes. For dynamic links, you must enter the link of the language. For example, in the language string like the following code.

<!--?php if(qtrans_getLanguage() == "en") : ?--><a href="https://www.luiginervo.net/en/how-to-make-a-multilingual-website-on-wordpress/999/">text</a><!--?php endif ?-->

To fix a bug in the menu, we have to add the following code in the file functions.php.

add_filter('walker_nav_menu_start_el', 'qtrans_in_nav_el', 10, 4);
    function qtrans_in_nav_el($item_output, $item, $depth, $args){
        $attributes  = ! empty( $item-&gt;attr_title ) ? ' title="'  . esc_attr( $item-&gt;attr_title ) .'"' : '';
        $attributes .= ! empty( $item-&gt;target )     ? ' target="' . esc_attr( $item-&gt;target     ) .'"' : '';
        $attributes .= ! empty( $item-&gt;xfn )        ? ' rel="'    . esc_attr( $item-&gt;xfn        ) .'"' : '';
       // Determine integration with qTranslate Plugin
       if (function_exists('qtrans_convertURL')) {
          $attributes .= ! empty( $item-&gt;url ) ? ' href="' . qtrans_convertURL(esc_attr( $item-&gt;url )) .'"' : '';
       } else {
          $attributes .= ! empty( $item-&gt;url ) ? ' href="' . esc_attr( $item-&gt;url ) .'"' : '';
       $item_output = $args-&gt;before;
       $item_output .= '&lt;a'. $attributes .'&gt;';
       $item_output .= $args-&gt;link_before . apply_filters( 'the_title', $item-&gt;title, $item-&gt;ID ) . $args-&gt;link_after;
       $item_output .= '';
       $item_output .= $args-&gt;after;
       return $item_output;

Obviously, you should replace en with the correct language codes. About dynamic links, you must enter the link of the language. For example, fixing the string language like the following. How can you manage a Seo optimizion for a website that uses the multilingual WordPress plugin qTranslate? We have seen that it is easy to change title, description and keywords thanks to the language codes that are accepted by the All in One SEO Pack plugin. But it is not possible to translate the URL which is very important for indexing on Google and on the search engines. To fix this problem, you just have to install the plugin qTranslate slug with Widget and replace the flags widget with the one that now is available. We can finally translate the URL of posts, pages and categories from the fields qTranslate Slug translation. Finally, do not forget the sitemap. The traditional ones are not good because they hardly consider the division into languages, but we can fix thanks to the plugin Google XML Sitemaps v3 for qTranslate. By doing so, you get a fully multilingual website in WordPress that is also optimized for Seo. I have personally tested the qTranslate plugin on my blog and on some websites made for customers. The evaluation? It is a shellbomb, but get help from a professional to avoid that it will explode in your hands.


Many of yu asked to me a consulting to install qTranslate plugin. My advice is to take a look to WPML and think about this plugin.This is a paid plugin, but it requires less effort to be installed or configured. The cost of consulting will be also lower and you will have a multilingual modul that is more effective and adaptable.

Articoli correlati

  • Cheap or free websites? Where is the catch?Cheap or free websites? Where is the catch? Do you want to create a cheap website? You can save money but pay attention to catches. Many people guarantee one minute made or free website, but with a thousand asterisks and annotations […]
  • Come fare un sito web multilingua su WordPressCome fare un sito web multilingua su WordPress Sempre più clienti chiedono un sito web multilingua per intercettare mercati esteri. Come fare su WordPress? La soluzione migliore è il plugin gratis qTranslate, ma non basta installarlo: […]
  • Profession webmaster, the website guardianProfession webmaster, the website guardian The webmaster is one of the most classic between the web professions. It is not only involved with the creation of websites, but their management and maintenance in compliance with […]

Leave a Reply

Your email address will not be published. Required fields are marked *