How to fix qTranslate changing languages when pressing home button

19 Mar

qTranslate is a WordPress plugin that allows you to install multiple languages for your blog. The only problem with it is that when you press the Home button, it will switch back to the default language. So, I searched for a fix for this problem, and I manage to find one that actually worked.

Problem:

qTranslate automatically changes languages when pressing Home button

Fix:

  • Locate your functions.php file in your theme directory on your FTP. If you can’t access FTP, go to Dashboard -> Appeareance -> Editor -> functions.php
  • open for edit
  • go to the end of the file, right before the last ?>
  • add the following code before ?> and press update/save

the code:

add_filter('wp_nav_menu_items','qtrans_in_nav_function');
function qtrans_in_nav_function ($nav){

$url = get_bloginfo('url');
$url_preg = preg_replace('/\//', '\/', $url);

$qtrans_url = qtrans_convertURL($url);

$nav = preg_replace('/('.$url_preg.')(\/id)/', $url, $nav);
$nav = preg_replace('/('.$url_preg.')/', $qtrans_url, $nav);

return $nav;
}

You’re done now! It should work if you refresh the page. If it’s not working, try it in a clean browser! It worked for me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: