Skip Navigation

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

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 7 replies, has 2 voices.

Last updated by Bruno Kos 1 year, 9 months ago.

Assisted by: Bruno Kos.

Author Posts
September 11, 2023 at 9:44 am #14374365

mohammadR-9

HI, sir when i tranlsate my english post another language then my post meta data fileds not copied, im using custom post meta data.. can you tell me how to solve this

September 12, 2023 at 8:13 am #14381299

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

Thank you for contacting WPML support!

Did you set these fields to "copy"? You can do it like this:
https://wpml.org/documentation/getting-started-guide/translating-custom-fields/#indicating-which-custom-fields-to-translate

Regards,
Bruno Kos

September 12, 2023 at 9:36 am #14382217

mohammadR-9

ok got it, one more thing, i have custom fields which i have changing multiple times like every months or weeks , i want to display same as my default, i have attached screen short, can you please tell me which filed i you are using to detect orignal post, i share my code

<?php
$downloads_links = get_post_meta($post->ID, 'downloads_links', true);

if (!empty($downloads_links)) {
$downloads_links = maybe_unserialize($downloads_links);
if (is_array($downloads_links) && !empty($downloads_links)) {
foreach ($downloads_links as $link) {
if (strpos($link, '.apk') !== false) :
?>
post_name; ?>/download/">

Download ()

<?php
break; // Exit the loop after the first APK link is found.
endif;
}
}
}
?>

i want to show orignal post submited these filed show all tranlstaed same posts, wheni change somehintg orignal post then auto changed translated

September 12, 2023 at 11:03 am #14382921

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

You can use this hook https://wpml.org/wpml-hook/wpml_object_id/ where you can find various examples.

You can retrieve the original post ID using the wpml_object_id function. Pass the current post's ID and the post type to get the original post's ID. Here's an example:

$current_post_id = get_the_ID(); // Get the current post ID
$original_post_id = wpml_object_id($current_post_id, 'post_type_name', false, 'original'); // Replace 'post_type_name' with your post type

If unsure how to work with this, you can always consult our https://wpml.org/contractors/

September 12, 2023 at 4:03 pm #14385321

mohammadR-9

wheni user
$current_post_id = get_the_ID(); // Get the current post ID
$original_post_id = wpml_object_id($current_post_id, 'post', false, 'original'); // Replace 'post_type_name' with your post type

echo $original_post_id; // getting orignal post id

Fatal error: Uncaught Error: Call to undefined function wpml_object_id()

Screenshot 2023-09-12 210057.png
September 12, 2023 at 4:23 pm #14385393

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

You need to use these through filters, following the code as on https://wpml.org/wpml-hook/wpml_object_id/.

I can't code this for you, this is outside of the support scope.

Please consult our https://wpml.org/contractors/ for further help on how to use these functions.

September 12, 2023 at 5:10 pm #14385611
mohammadR-9

ok sir, i sllved my this problem, one more thing i have translated myorigal post in two languages, and when i open translated category
hidden link

then they not found, redirect to homepage

New threads created by Bruno Kos and linked to this one are listed below:

https://wpml.org/forums/topic/split-posta-meta-data-not-copy/

September 13, 2023 at 6:46 am #14387161

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

I split this topic into a new one, for our support rules, and will reply there.