Im using Qtranlate plus (https://wordpress.org/plugins/qtranslate-xp/) and i also use Wordpress seo by Yoast but the meta title and description fields cant be translated. Anyone have a fix for that or knows a plugin that fixes the issue?
This Problem exists since qTranslate wasn't plus. There is a fix, from Yoast: http://kb.yoast.com/article/52-wordpress-seo-qtranslate
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 );
add_filter( 'wpseo_opengraph_title', 'qtranslate_filter', 10, 1 );
This wasn't enough for me... i traced the $text and saw that the language syntax was broken. It wasn't
<!--:de-->, it was <!-:de->.
So i added a replacement for that directly in the qtranslate_filter($..).
function qtranslate_filter( $text ) {
$fixedOpenTag = str_replace("<!-:", "<!--:", $text);
$fixedCloseTag = str_replace("->", "-->", $fixedOpenTag);
return __($fixedCloseTag);
}
This works for frontend output. I looked in the sourcecode of yoast but haven't fixed it by now...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With