Skip Navigation

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.

Tagged: 

This topic contains 12 replies, has 2 voices.

Last updated by Alejandro 4 months ago.

Assisted by: Alejandro.

Author Posts
October 21, 2024 at 6:42 pm #16314045

johnsutton

Background of the issue:
I am trying to ensure that the post on the home page of my site in the primary language links correctly to the corresponding post in the secondary language when the language switcher is clicked. The primary home page is hidden link and the secondary home page is hidden link. I have tried clearing the server cache, resaving permalinks, and using the Translate Link Targets feature in WPML settings.

Symptoms:
The post on the home page in the primary language is not linking to the corresponding post in the secondary language when the switcher is clicked.

Questions:
Why is the post on the home page in the primary language not linking to the corresponding post in the secondary language?
What additional steps can I take to resolve the issue of unsynchronized home pages?

October 21, 2024 at 6:59 pm #16314150

johnsutton

I do have "Copy publishing date to translations" option enabled in WPML > Settings

and see that the publishing dates in the primary and secondary languages are different and many post-translations are misaligned.

This hasn't been an issue in the past so I must have done something to cause this but I don't know what.

October 22, 2024 at 2:27 pm #16318036

johnsutton

Hi,

I have not yet received a reply so I've continued to try and find some resources in the knowledge base that appears similar to my issue such as: https://wpml.org/forums/topic/my-posts-publishing-date-are-being-incorrectly-translated-as-the-current-date/

In the suggested steps I do not see a "Post and Pages synchronization" option to disable in the "Posts and pages synchronization" section to disable as described.

See attached screenshot of Dashboard > WPML > Settings > Posts and pages synchronization

Screenshot 2024-10-22 at 10.24.29 AM.png
October 23, 2024 at 5:40 pm #16323023

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Hello there!

First of all, I want to apologize for you waiting so long for a reply

1) with the settings you showed me, you should have your posts synced IF they were created after the setting was checked ("copy publishing date to translations"), that will only happen when you translate the content for the first time. However things may change if you initially translated the content when the page was a draft (because at that stage there is not publishing date). I don't think this is linked to the main issue of this ticket but I'll be more than happy to help yo get to the bottom of this issue 🙂

2) You mention a problem with the link in the language switcher but i don't see it. the language switcher is linking to both pages correctly on my end. Am I missing something?

This is what I see: hidden link

Regards,

October 23, 2024 at 6:29 pm #16323178

johnsutton

HI Alejandro!

No worries on the delayed response and thank you for helping me.

Here is a video (4-min) that I hope gives you a better idea of the issue.

hidden link

Thanks!

John

October 24, 2024 at 4:22 pm #16327427

johnsutton

Hi Alejandro...

It's been 22 hours since I sent a reply and haven't heard back. Do you have any updates to share?

Thanks!

John

October 24, 2024 at 5:27 pm #16327712

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Quick question: in what timezone are you in? because i suspect that our timezones are very far apart and if that's the case i can transfer the case to someone near your timezone (I'm located in Italy).

Would it be possible to have access to your site? i want to check how a few things on your site are configured so i can probably find a solution. i suspect it's something "easy" but that might not be too on the nose, but your video made things way clearer!

I have enabled the credential fields so you can share them private and securely.

--------------

You can create a fake user and add the credentials in the box i mentioned above (fake mail, username of your choice and a password), this way you control the user entirely and can delete it when you want.

Regards,

October 25, 2024 at 4:04 pm #16331633

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

I tried to find out where you edit the homepage but couldn't find it and there doesn't seem to be a page for it, it seems to be part of the theme. can you customize what post is used? like can you select a category, a set of posts or something else?

If so, where can i see that?

---------

I'm running a few tests on your site but i believe we may have a bug about this.

Do you have a site backup?

If so you try to run this query in the meantime:

UPDATE wp_posts p
JOIN wp_icl_translations t1 ON p.ID = t1.element_id
JOIN (
    SELECT t.trid, p.post_date
    FROM wp_icl_translations t
    JOIN wp_posts p ON t.element_id = p.ID
    WHERE t.source_language_code IS NULL
    AND t.element_type = 'post_post'
) AS source_posts ON t1.trid = source_posts.trid
SET p.post_date = source_posts.post_date
WHERE t1.element_type = 'post_post'
AND t1.source_language_code IS NOT NULL;

If you don't know how to do so, i can do it for you with your permission. I would also run a backup of the database before i do anything.

Regards,

October 25, 2024 at 5:44 pm #16331908

johnsutton

Hi Alejandro!

In Dashboard > Settings > Reading, the first section "Your homepage displays" is set to "Your latest Posts" and not a page.

I'm going to try setting the posts to a dedicated page and see if that works. I'll let you know what happens.

Thank you,

John

October 25, 2024 at 7:59 pm #16332139

johnsutton

Hi Alejandro,

I set a static page for blog posts in Dashboard > Settings > Reading [settings below]

Toggling English/Spanish produces the the same result as setting "Homepage Displays" to "Your latest posts." Screenshots below

STATIC PAGE SETTINGS
Home Page: -Select-
Posts Page: Home & Blog

I've backed up the site at WPEngine so please run the query you mentioned.

Thanks fo the help!

John

02_SPANISH Static page.png
01_ENGLISH Static Page.png
October 26, 2024 at 8:56 am #16332988

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

All Done!

I have left a PRIVATE post as an example of my test, it can only be seen by admins so you can delete them when you want 🙂

Please watch this video to see exactly all that i did, so you can do it later if you want 😀 --> hidden link

There wasn't a bug in the end, the problem here was that you have set that the translations are first saved as a draft. initially, when they are drafts they have the correct publishing date, however when you click the publish button, WordPress will add a new publishing date, since you just "published it" at that moment and that's what happened there!

There were only 17 elements like that. if you want to change that, you can go to WPML > Settings > Translated documents options > When you publish the original post.

Select "Publish the post translations"

Regards,

October 26, 2024 at 2:45 pm #16333425

johnsutton

Hi Alejandro,

Thank you for your detailed instruction video.

I enabled "WPML > Settings > Translated documents options > When you publish the original post" as suggested.

Thank you also for showing me how to run this query on the DB posts table which put everything right again.

UPDATE wp_posts p
JOIN wp_icl_translations t1 ON p.ID = t1.element_id
JOIN (
SELECT t.trid, p.post_date
FROM wp_icl_translations t
JOIN wp_posts p ON t.element_id = p.ID
WHERE t.source_language_code IS NULL
AND t.element_type = 'post_post'
) AS source_posts ON t1.trid = source_posts.trid
SET p.post_date = source_posts.post_date
WHERE t1.element_type = 'post_post'
AND t1.source_language_code IS NOT NULL;

Regards,

John

October 28, 2024 at 7:24 am #16336015

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Do you have any other posts planned? because if you can, you can try to follow your workflow now with this new method and see if it works ok now.

Let me know how it goes.