Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In some cases language switcher is not working correctly #98

Open
KMantas opened this issue Sep 18, 2024 · 0 comments
Open

In some cases language switcher is not working correctly #98

KMantas opened this issue Sep 18, 2024 · 0 comments
Assignees

Comments

@KMantas
Copy link

KMantas commented Sep 18, 2024

As I understood wpml_permalink_filter inside class-custom-permalinks-frontend.php
is used to solve language switcher issues, but in my case it is not working. My language setting is: domain/lang-code.
This code:
trailingslashit( home_url() )
returns home page with language, then if translated post has same permalink then wpml_permalink_filter points to current language instead of translated.
For my case temporary fix is this:
replace
$trailing_permalink = trailingslashit( home_url() ) . $custom_permalink;

with:

if ($language_code) {
			$trailing_permalink = trailingslashit(get_option( 'home' )) .trailingslashit($language_code) .$permalink;
		} else {
			$trailing_permalink = trailingslashit( home_url() ) . $custom_permalink;
		}

but probably it is not correct for all cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants