[Plugin: Polylang] Language homepage redirection problem and solution (but incomplete)
-
Thank you Chouby and everyone who contributes to this plugin.
This was my first attempt to make a WordPress powered site/template in various languages and really love the way Polylang works, with different permalinks for each language and letting you decide what to translate. It’s really flexible and not obstructive. A very intelligent approach. I love the way it works with widgets.My settings are:
– Remove /language/ in pretty permalinks. Example: https://lisboaautentica.com/en/
– Hide URL language information for default language
– Add language information to all URL including posts, pages, categories and post tags (not recommended)My permalink structure is:
/%year%/%monthnum%/%day%/%postname%Notice the missing trailing slash. I prefer URLs of the type https://domain.com/about-us (instead of https://domain.com/about-us/).
Now, the only problem i found was when i was visiting the homepage for some language (say “/es”) the “redirect_canonical” filter in “core.php” was responding with a 404 and redirecting to “/es/” (with trailing slash).
So I changed the filter hook to this:
function redirect_canonical($redirect_url, $requested_url) { //return $requested_url == home_url() || $requested_url == $this->page_link('', get_option('page_on_front')) ? false : $redirect_url; return is_home() || $requested_url == $this->page_link('', get_option('page_on_front')) ? false : $redirect_url; }
This solved the 404/redirect problem.
But now I have 2 valid URLs for the language homepage:
“/es” and “/es/” both give me the same content. And this is not good for SEO.I’, trying to fix this, but still didn’t find the best way to do it.
Any help will be appreciated and i hope it contributes to this plugin.Other info: I’m using Nginx and WordPress Multisite.
PS: i just made my donation ??
- The topic ‘[Plugin: Polylang] Language homepage redirection problem and solution (but incomplete)’ is closed to new replies.