Multisite-Language-Switcher
Multisite-Language-Switcher copied to clipboard
Link problem
Links to translated posts do not work like in Version 1.0.4.
Version 1.0.4 link structure: domain.tld/blog/post Version 1.0.6 link structure: domain.tld/post
Changing site settings or perma link structure has no effect.
Thanks. I will check this now.
I experienced the same issue with translated posts. No matter if I change the permalink, the language switcher keeps redirecting me from /en/blog to /de and vice versa. Same issue with posts. Is there any solution for this by now? Thanks in advance.
Do you have an URL where I can see this?
Thanks for the quick reply. The url is the following: http://quercusapp.com . If you click on about then select blog and you press on 'DEUTSCH' it jumps to the frontpage of the german version, although the german blog is selected in the language switcher. Same goes with posts. We struggled hours with figuring out what could cause this and haven't been able to solve this yet. Thank you for helping us!
Is that a problem with the plugin itself? Or are we not doing something correctly perhaps?(We just did the same thing as with the other pages). Or is the problem related to Wordpress?
This definitely needs to be fixed in the core code. For the time being, here is a function I wrote that generates all the data you need to output a custom language selector that actually works as intended.
public function get_language_options()
{
global $post;
$blogs = MslsBlogCollection::instance()->get_objects();
$posts = ($post) ? get_option('msls_' . $post->ID) : [];
$current = null;
$links = [];
foreach($blogs as $blog) {
$language = $blog->get_language();
if ($blog->userblog_id == MslsBlogCollection::instance()->get_current_blog_id()) {
$current = $language;
}
// if linked post doesn't exist, link to homepage
$links[$language] = $blog->path;
if (isset($posts[$language])) {
switch_to_blog($blog->userblog_id);
$links[$language] = get_permalink($posts[$language]);
restore_current_blog();
}
}
return [
'current' => $current,
'links' => $links
];
}