Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
SEO Meta Descriptions Missing on Duplicates
Solution:
Go to the Dashboard > Pages.

Select your pages

Bulk actions > Edit > Apply and Update.

Relevant Documentation:

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.

This topic contains 5 replies, has 2 voices.

Last updated by charlesS-27 1 year, 10 months ago.

Assisted by: Bobby.

Author Posts
June 15, 2022 at 8:38 pm #11470687

charlesS-27

We have a United States page:

hidden link

And a Canadian Version as a Duplicate :

hidden link

On the Canadian version there is no meta description at all even though it shows up in the wordpress backend.

Looks like the Yoast SEO fields are not synchronizing to the duplicates when the original is updated.

Yes, the WPML SEO connector plugin is installed and updated to the latest 2.0.1

CABackend.JPG
CAmetaError.JPG
June 16, 2022 at 1:00 am #11471335

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hello,

When I view the hidden link page I am not able to see an existing default language page. If possible, please verify it is published.

Apart from this, I was able to reproduce this behavior in a sandbox environment.

When a page does not have any content and just a title (most times the case with post pages) and it's a duplicate the Yoast SEO meta description will not display.

A way around this is to set the custom field _yoast_wpseo_metadesc from WPML->Settings->Custom Fields translation to "Copy once" and then add some content apart from a title.

However, I'd suggest against this if you need to have translated meta descriptions as it would disrupt the rest of the seo meta descriptions.

My recommendation is to translate the page independently as that would resolve this issue.

Go to pages and edit the page->switch to the translation language (dismiss any warnings) and click on 'translate independently' then add the desired meta description.

Let me know your results, please.

Screen Shot 2022-06-15 at 6.00.12 PM.png
June 16, 2022 at 4:05 pm #11478453

charlesS-27

Hi Bobby,

Thanks for the response. Ah yes that is not a great example as the US version has been taken down. Sorry about that.

Interesting yes we do also maintain other languages so the copy_once is not a great solution.

I did also find that independent translation solves it. In our case the CA translation will almost always be an exact copy of US, it would be a lot less work to have duplicates auto synchronize. I am a developer so a little custom function could do the trick.

What about something like so?

Auto Sync Dupes.JPG
June 16, 2022 at 4:31 pm #11478621

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Thank you for sharing the code with us! I have already taken steps to discuss this behavior with our compatibility team.

I will make sure to share this code with them and update you here once there are news

June 20, 2022 at 3:13 pm #11501159

charlesS-27

Hi Bobby,

I have come up with a solution. Though I'd share it with you.

Solved sync'ing the yoast meta on master post updates like so:

//WPML - Sync Meta on Master Update
add_action( 'updated_post_meta', 'wpml_duplicate_sync_update', 999, 4);
function wpml_duplicate_sync_update($meta_id, $post_id, $meta_key, $meta_value) {
//Meta Key Whitelist
if($meta_key != '_yoast_wpseo_metadesc') {return;}
//Copy To My WPML Duplicates
$myDuplicates = apply_filters('wpml_post_duplicates', $post_id);
foreach($myDuplicates as $lang => $dup_post_id){
update_post_meta($dup_post_id, '_yoast_wpseo_metadesc', $meta_value);
}
}

Then ran into an issue where yoast indexing would not fire during wpml duplicate creation when the post meta is updated even though it is supposed to be listening.

This is the solution I came up with:

//WPML - Sync Yoast Index on Duplicate Creation
add_action( 'icl_make_duplicate', 'wpml_duplicate_sync_insert', 999, 4);
function wpml_duplicate_sync_insert($master_post_id, $lang, $post_array, $id) {
duplicate_yoast_index($master_post_id,$id);
}

//Duplicate Yoast Index
function duplicate_yoast_index($src_id, $dest_id){
global $wpdb;
$SQL = "UPDATE
{$wpdb->prefix}yoast_indexable AS dest,
(
SELECT
*
FROM
{$wpdb->prefix}yoast_indexable
WHERE
object_id = %d
) AS src
SET
dest.title = src.title,
dest.description = src.description
WHERE
dest.object_id = %d
";
$wpdb->query($wpdb->prepare($SQL,$src_id, $dest_id));
}

Hope that helps and can make its way into WPML. I'm sure others could benefit.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.