Skip to content Skip to sidebar

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 17:00 10:00 – 17:00 10:00 – 17:00 10:00 – 17:00 10:00 – 17:00 -
- 18:00 – 19:00 18:00 – 19:00 18:00 – 19:00 18:00 – 19:00 18:00 – 19:00 -

Supporter timezone: Asia/Kathmandu (GMT+05:45)

This topic contains 8 replies, has 0 voices.

Last updated by Shekhar Bhandari 1 week ago.

Assisted by: Shekhar Bhandari.

Author Posts
June 20, 2025 at 10:05 am #17153690

tobiasW-40

Background of the issue:
I am trying to edit a page, save using the autosave feature, and preview the changes using the WordPress preview feature on a site that has been published in multiple languages. After debugging, I found that the behavior is triggered through the 'parse_query' hook action defined in 'sitepress-multilingual-cms/sitepress.class.php': <code> add_action( 'parse_query', array( $this, 'parse_query' ) ); </code> Commenting out this line leads to the preview being loaded correctly, but it also disables most of the routing functionality of WPML, so translated sites are not displayed correctly anymore on the published site.

Symptoms:
The preview of the page is heavily outdated, showing a version from two years ago instead of the latest changes. The query used with WPML has a hardcoded ID, which always returns the post/page with ID 44, not the latest revision.

Questions:
Why does the preview show an outdated version of the page?
How is the ID 44 determined in the query with WPML?
How can I fix the preview issue without disabling WPML's routing functionality?

June 24, 2025 at 7:54 am #17163335

Shekhar Bhandari
WPML Supporter since 03/2015

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Thank you for contacting WPML support. I'd be happy to assist you on this issue.

I have a test site setup here: hidden link

Can you check if you can reproduce the issue here? Also if yes, can you provide me clear steps to reproduce so I can check this further.

Look forward to your reply.

Thanks

June 26, 2025 at 7:22 am #17171624

tobiasW-40

Hi,

thanks for your response. I tried to reproduce the issue on your site. Sadly I was not able to. One main difference I see is that on our site we are using the WP Bakery Plugin in combination with WPML. I was not able to install that plugin on your site though.

I actually provided detailed steps on reproducing the issue in this support request initially but the AI summary feature of this forum stripped all that away...

I will try to give a more detailed view here again:

The issue happens when editing a translated page and clicking the "Preview Changes" in the classic (non-gutenberg) editor. Debugging it shows that there is an autosaved revision created correctly when editing the page. Performing the query to fetch the latest revision on the database gives the correct content.

However the preview page calls the 'parse_query' hook of the WPML plugin. This hook somehow determines that the preview should show an outdated version of the page and attaches the id of that revision into the query parameters. That leads to the lookup of the latest version be useless as it already includes the hardcoded id of the revision.

The SQL Query without the WPML plugin looks lilke this:

SELECT
	sg9014_posts.ID
FROM
	sg9014_posts
WHERE
	1 = 1
	AND sg9014_posts.post_parent = 2745
	AND sg9014_posts.post_type = 'revision'
	AND ((sg9014_posts.post_status = 'inherit'))
ORDER BY
	sg9014_posts.post_date DESC

The SQL Query WITH the WPML plugin (and therefore parse_query hook) looks like this:

SELECT
	sg9014_posts.ID
FROM
	sg9014_posts
WHERE
	1 = 1
	AND sg9014_posts.ID = 4469
	AND sg9014_posts.post_parent = 2745
	AND sg9014_posts.post_type = 'revision'
	AND ((sg9014_posts.post_status = 'inherit'))
ORDER BY
	sg9014_posts.post_date DESC

Notice that in the second query the posts.ID is already set. I am assuming this information is coming from some internal cache that WPML is using to determine the revision. Do you have some more information on whats the mechanism there so I can further debug? Maybe you can tell me how I can reset the internal cache if there is something like that?

Thanks!

June 26, 2025 at 7:34 am #17171646

tobiasW-40

Actually I just tried to clear the WMPL cache and any other cache I could think of but this didn't resolve the issue. Would be glad for further ideas on how to debug this.

June 26, 2025 at 12:18 pm #17173411

palasthotelG

Hi, we have the same setup (WPBakery and WPML) and have the same problem: previews of translated pages refuse to show the latest changes.

Here's what I gathered before I found this post:
- WordPress 6.8 made changes to the wp_get_post_autosave-function in `wp-includes/revision.php`: hidden link
- Preview in WordPress 6.7.2 worked
- WPML makes adjustments to the query in the `parse_query`-function in `classes/query-filtering/class-wpml-query-parser`
- it happens in line 380 when $this->maybe_adjust_name_var is called

After that I gave up and found this here...

Right now we downgraded WordPress to 6.7.2 to have at least a functioning workflow, but that can only be temporarily!

June 26, 2025 at 1:00 pm #17173597

Shekhar Bhandari
WPML Supporter since 03/2015

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Since the issue is not happening with the sandbox site, To debug this issue further, I would need to check your site settings once, for this I would need temporary access (wp-admin and ftp) to your site.

So could you please provide me with those details, you will find the needed fields for this below the comment area when you log in to leave your next reply.
hidden link

This info is private and available to you and WPML supporters only.
Read more about this: https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

Note:
Backup your sites before providing the credentials or if possible provide credentials for the test site

Look forward to your reply.

Thanks

July 4, 2025 at 10:27 am #17200999

palasthotelG

Hi Shekhar,

I set up a test site with a test user where you can see the problem:

login: hidden link

You only have restricted access to the site. I can't give you more. And definitely no ftp access.

Check the problem on this site: hidden link
Make some changes and click on preview.
The preview doesn't work. If you deactivate WPML, it works.

Check my former comment, it details where the problem occurs in the plugin code. On the live site I hacked the wordpress-core and downgraded the changes in "wp-includes/revision.php" to the version in 6.7.2. then it also works with the plugin.

Ok... I was stupid - please contact me for the credentials to the test site.

July 8, 2025 at 9:12 am #17212674

palasthotelG

@shekard Could you send me a new request for a private reply?

I would like to share the credentials to the test site with you

July 9, 2025 at 10:00 am #17218128

Shekhar Bhandari
WPML Supporter since 03/2015

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Sure, I have enabled the private reply for you.

Thanks