Sorry, I cannot recommand you any seo plugin because I just didnt test them all… I think Yoast SEO plugin works fine with sublanguage, though its not really lightweight.
What is this seo plugin you’re talking about?
Hi,
I have tried to use this one (don’t really like Yoast, it’s much to complicated)
https://ww.wp.xz.cn/plugins/autodescription/
I tried to use the [:en]English text[:de]German text
but it did not work. They say it works with the qtranslate though.
You can translate this plugin meta description and meta title by adding the following in your function.php file:
add_filter('sublanguage_register_postmeta_key', 'my_translate_postmeta');
function my_translate_postmeta($postmeta_keys) {
$postmeta_keys[] = '_genesis_description';
$postmeta_keys[] = '_genesis_title';
return $postmeta_keys;
}
Unfortunately this won’t work when the description or title meta field is left empty: the meta description or title will always default to your main language post content or title. So you must make sure meta description and title are filled on every post, when not in main language.
Hi maximeschoeni,
Could you provide a little snippet for me where I can interact with the current language(s) of the post in question?
Do the different languages have a self assigned post_ID for the posts or do they differ each time based on some meta variable while the post_ID stays intact?
Thank you so much!
Hello,
Extra-languages data of posts are stored in a custom post parented to this post. These children “translations” posts have also a specific post-type: “translation_{$id}”, where $id is a general id for this language.
This is a very basic snippet to interact with sublanguage.
You can find more info on github
global $sublanguage;
// or global $sublanguage_admin when in admin.
$some_post = get_post(123);
// this will be the "main language" post
$current_language_id = $sublanguage->current_language->ID;
// the current language id.
// should be $sublanguage_admin->current_language->ID; wen in admin.
$translation_post = $sublanguage->get_post_translation($some_post->ID, $current_language_id);
// this is the "sub language" post (if actually on a "sub" language).
// it stores translations in post_content, post_title, post_name and post_excerpt fields.
$post_meta = get_post_meta($some_post->ID, 'some_meta_key');
// this is automatically translated according to the current language if post meta was previously registrated with 'sublanguage_register_postmeta_key' filter
Please ask me if you need more specific informations.
Thank you so much for your time and dedication! Keep up the good work :).