Wordpress + Polylang - Error 404 when trying to preview draft post on different language

admin2025-01-07  6

So, i installed Polylang and the problem I am facing is related to the post preview function on my WordPress website. When I preview a post on different language than default, it takes me to a 404 error page unless I manually change the domain from the current one to the ".cz" domain. (I'm using different TLD for every language). I want to find a solution that will allow the post preview function to work properly with the Polylang plugin with every language.

All updates are installed, everything is up to date.

Thank you!

So, i installed Polylang and the problem I am facing is related to the post preview function on my WordPress website. When I preview a post on different language than default, it takes me to a 404 error page unless I manually change the domain from the current one to the ".cz" domain. (I'm using different TLD for every language). I want to find a solution that will allow the post preview function to work properly with the Polylang plugin with every language.

All updates are installed, everything is up to date.

Thank you!

Share Improve this question asked Apr 27, 2023 at 9:43 moqer109moqer109 1
Add a comment  | 

1 Answer 1

Reset to default 0

I know that i'm 2 late, but i had the same problem. I rewrote the urls to ignore polylang functionality like this:

if ( (isset($_GET['page_id'])) || (isset($_GET['preview']) && $_GET['preview'] === 'true') ) {
    $query->query_vars['pagename'] = '';
}

The problem is that the polylang adds /{new-language}/ to the url, but WP treats it as a page. This function ignores this and essentially solves the problem

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736258898a548.html

最新回复(0)