WordPress – QTranslate and Yoast SEO
A client’s WordPress website needed some love in regards to its SEO and as it is a multilingual site, it has QTranslate in combination with Yoast SEO.
For the most part these 2 plugins work great individually, but when combined there are some serious issues with SEO of foreign languages with regards to meta title and meta description tags for pages and posts.
After hunting around a little in the search engines I was terribly relieved to find a post on the WordPress forum, which provided some awesome insights. However, there still appeared to be a problem with the title tags, and I was not able to determine a solution that I found satisfactory.
Some investigation seemed to come up with a suitable result. So if you are having issues, consider following the instructions below and see how you get on. I would really, really appreciate your feedback as I have only recently implemented this change so thorough testing has yet to be conducted. Please note that the standard QTranslate syntax will need to be used for the meta title and description (e.g. <!–:en–>English<!–:–><!–:es–>Spanish<!–:–>).
From the forum post linked above, add the following into the functions.php script of the theme you are using:
// Enable qTranslate for WordPress SEO
function qtranslate_filter($text){
return __($text);
}
add_filter(‘wpseo_title’, ‘qtranslate_filter’, 10, 1);
add_filter(‘wpseo_metadesc’, ‘qtranslate_filter’, 10, 1);
add_filter(‘wpseo_metakey’, ‘qtranslate_filter’, 10, 1);
and that works fine with exception to the title tag (UPDATE 4th July 2013 – please double check this for the latest version of Yoast, as this might now be resolved).
For the title tag I made the change to the Yoast plugin file /wp-content/plugins/wordpress-seo/frontend/class-frontend.php, which included replacing the line:
return esc_html( strip_tags( stripslashes( apply_filters( ‘wpseo_title’, $title ) ) ) );
with:
return esc_html( strip_tags( stripslashes( apply_filters( ‘wpseo_title’, wpseo_get_value( ‘title’ ) ) ) ) );
Save and check. This appears to work fine for me, but please try for yourself and let me know your feedback in the comments section below.
Many thanks and happy translating. 🙂
UPDATE – 28th Nov 2012 (SUPERSEDED BY 4th JULY 2013 UPDATE BELOW)
The above solution works with Yoast versions 1.2.8.7 or older.
If your version of Yoast is 1.3 or newer the above solution will not work (your qTranslate code will be stripped out when you save). We are currently working on a fix and will post it here when completed. If you would like to be emailed once we’ve found a fix, just post “Please let me know when you’ve found the fix for Yoast version 1.3+” in the comments box below.
If you can’t wait until then, Yoast version 1.2.8.7 will do the trick in the meantime.
UPDATE – 4th July 2013
Thanks to a comment from Solala (see in the comments section below), it would seem there’s now a fix for Yoast versions 1.3+!
I haven’t had a chance to personally test these options, so please backup your files before making these changes.
I would love to know which fix works for you – feel free to post your results in the comments section below.
(Thanks and kudos goes to Pedro Carvalho and b_machuel who posted their solutions here)
OPTION 1
In the file /wp-content/plugins/wordpress-seo/frontend/class-frontend.php replace the title() function with this:
function title( $title, $sepinput = ‘-‘, $seplocation = ” ) {
return $title;
}
OPTION 2
In the file /wp-content/plugins/wordpress-seo/frontend/class-frontend.php
} else if ( $this->is_home_posts_page() ) {
$title = $this->get_title_from_options( ‘title-home’ );
// START CHANGES
// Changed to tackle multilingual issue on posts page
} else if ( $this->is_posts_page() ) {
global $q_config;
$title = qtrans_use($q_config[‘language’], $this->get_content_title( get_post( get_option( ‘page_for_posts’ ) ) ), true);
// Added to tackle multilingual issue on pages
} else if ( is_page() ) {
global $q_config;
$title = qtrans_use($q_config[‘language’], $this->get_content_title(), true);
// END CHANGES
} else if ( is_singular() ) {
$title = $this->get_content_title();
OPTION 3
The awesome Yoast have added a solution to their FAQ which is identical to our original functions.php solution above, so this alone may now work with the latest version of Yoast without needing any of the other code alterations listed above (this is yet to be 100% confirmed by the user community). Note that some users have had issues with the single quote marks (‘) used in some of the code solutions posted in the WordPress forums, so please double check your single quote marks, or if in doubt you can get the original code from Yoast’s FAQ.
theo
Hey,
Thks for your tips.
I tried but it doesnt worked in my case : http://www.empereur-immobilier.com
The meta title doesn’t not appear (the browser shows the url and not the title).
Any idea ?
Many thks in advance
Sara Thornton
Hi there,
Thanks for your post. I just had a look at this page and the browser title seems to be changing from French to English as expected: http://www.empereur-immobilier.com/annonces-vendues/ and http://www.empereur-immobilier.com/en/annonces-vendues/
Did you manage to resolve the issue? Or are you seeing a problem with specific pages?
Thanks,
Sara
theo
Nope, I disabled the pluggin. I retry today and it sounds good. I don’t know why.
Sara Thornton
Hi Theo,
Thanks for the update – sometimes this can be a cached page issue (i.e. not seeing the newly updated page), and often clearing your Joomla cache, and/or force refreshing your browser (CTRL + F5 a few times) can instantly fix the problem.
Glad it all got sorted,
Sara
Ravi
Hi there Sara
Been trying the above fix but wp keeps stripping away the qTranslate syntax from the Yoast plugin 🙁
Any ideas?
Kind regards
Ravi
Sara Thornton
Hi Ravi,
Thanks for your post – can you let me know what versions of WordPress, qTranslate and Yoast you are using?
Thanks,
Sara
Sara Thornton
Hi Ravi,
We’ve carried out some testing, and it would seem that the Yoast version is the cause.
The above solution works with Yoast versions 1.2.8.7 or older.
If your version of Yoast is 1.3 or newer the above solution will not work (your qTranslate code will be stripped out when you save). We are currently working on a fix and will post it here when completed.
If you can’t wait until then, Yoast version 1.2.8.7 will do the trick in the meantime.
All versions of Yoast can be found here: http://wordpress.org/extend/plugins/wordpress-seo/developers/
I hope this helps,
Sara
Francesco
the right answer for me has been wp-i18n http://wordpress.org/extend/plugins/wp-i18n/ with SEO by Yoast.
One different page for each language and a more organized SEO.
Mirta Roma
Please let me know when you’ve found the fix for Yoast version 1.3+
Thomas
Please let me know when you’ve found the fix for Yoast version 1.3+
Thanks.
frizz
Please let me know when you’ve found the fix for Yoast version 1.3+
Nasik
Please let me know when you’ve found the fix for Yoast version 1.3+
Thanks
Szépe Viktor
Please let me know when you’ve found the fix for Yoast version 1.3+
Tom
Please let me know when you’ve found the fix for Yoast version 1.3+
Sebastian
Please let me know when you’ve found the fix for Yoast version 1.3+
solala
Solution for Yoast 1.3 or newer is posted here:
http://wordpress.org/support/topic/plugin-wordpress-seo-by-yoast-compatibility-with-qtranslate?replies=30#post-4380612
Meanwhile it is also mentioned in Yoast FAQ:
http://yoast.com/wordpress/seo/faq/#why-doesnt-the-wordpress-seo-plugin-with-qtranslate
You may consider to include me in your evening prayers 😉
Sara Thornton
Thanks for your post Solala!
I’ve checked out the links and users do indeed seem to now have success with Yoast version 1.3+. Hurrah!
I haven’t had a chance to test this personally yet, however any feedback would be warmly welcome to help any future people who stumble across this page.
Many thanks for your post!
Best wishes,
Sara
Sara Thornton
To all who were patiently waiting for the fix for Yoast version 1.3+, your wait is over!
We’ve updated our article, and the solution can be found here: https://www.webholism.com/blog/webholism/wordpress-qtranslate-and-yoast-seo/
Your feedback is greatly appreciated!
Thanks,
Sara
Serge
I really have a hard time with this plug-in.
You had show us how to modify the code in Yoast plug-in.
Our web creator made the modifications proposed here.
But after this, how to add an English title and description to a page created in French ?
This is supposed to be an easy plug-in for dummies like me.
Sara Thornton
Hi Serge,
Thanks for your post.
If you’ve got both qTranslate and Yoast installed, and you’ve applied the fixes mentioned in this article, then you should be able to just pop the qTranslate text into the Yoast Title and Meta Description boxes that should be located underneath the page that you are editing.
Put
in the Yoast Title box
in the Yoast Description box
and
Any problems, just let me know.
Thanks,
Sara
Omnigraf
Hi there,
I applied the official modifications proposed by Yoast to the functions.php file, then put “English titleItalian title” into the Yoast title and description boxes, but right after saving the changes, all I get is “English titleItalian title” one after each other and anything else happen.
Any ideas?
Sara Thornton
Hi Omnigraf,
Thanks for your post.
Did you try any of the class-frontend.php changes suggested in this article?
Thanks,
Sara
joris
Hi,
if I follow the instructions above the EnglishSpanish tags are being stripped when saving, so the title tag and meta contains all languages instead of the right one.
Sara Thornton
Hi Joris,
Are you using Yoast 1.3 or higher?
If so, could you confirm which of the 3 above suggested options you tried? Or did you try all 3?
Thanks,
Sara
Nico
I added the code to the functions.php file and ALMOST everything is working. The problem is the Meta Tittle is being display twice in the same language as you can see in my site(www.chacrasdecoria.travel).
Anyone know how to solve it?
Thanks!
Sara Thornton
Hi Nico,
Thanks for your post. Did you follow the /wp-content/plugins/wordpress-seo/frontend/class-frontend.php change also, or the Option 1, 2 or 3 from the 4th July 2013 update above (depending on your version of Yoast)?
Thanks,
Sara
GEv
Where i must put in the function.php in which line?
Please answer me
Sara Thornton
Hi GEv,
You should be able to add the “// Enable qTranslate for WordPress SEO” code to the bottom of the functions.php file for the theme you are using. Please always back up your files before making any changes, and test thoroughly afterwards.
Thanks,
Sara