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.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 -
- 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 4 replies, has 2 voices.

Last updated by Long Nguyen 1 year, 5 months ago.

Assisted by: Long Nguyen.

Author Posts
November 10, 2023 at 10:17 am #14774961

patriciaS-18

I'm trying to get WPML to translate IDs stored in the postmeta table, using a wpm-config.xml file, we added this line :

November 14, 2023 at 6:46 am #14793633

patriciaS-18

Hello,
Do you have any news?

November 16, 2023 at 6:54 am #14822179

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi Patricia,

Thank you for contacting WPML support, I'd be happy to help you with this issue.

If you want to translate a number field (not only the post ID), and you've registered the custom field for translation please go to WPML > String Translation > Search for the value and translate it.

Or add the code below to the file functions.php in the theme/child theme folder

function wpmlsupp_7499_allow_translating_numbers( $is_translatable, $job_translate ) {
    $data = $job_translate['field_data'];
	if ( 'base64' === $job_translate['field_format'] ) {
		$data = base64_decode( $data );
	}
    if ( is_numeric( $data ) ) {
    	return true;
    }
    return $is_translatable;
}
add_filter( 'wpml_tm_job_field_is_translatable', 'wpmlsupp_7499_allow_translating_numbers', 10, 2 );

to translate the number field in the WPML translation editor.
❌ IMPORTANT: Please backup your database and website before proceeding ❌

While checking the debug info, I see that the WordPress Memory Limit is below the requirements. The minimum requirements are 128M, but we do recommend 256M and the debug information of your site shows it set to 64M. Please check this link for more details
https://wpml.org/home/minimum-requirements/.
You can increase it by adding the following code in your wp-config.php file, right before the /* That’s all, stop editing! Happy publishing. */ line:

define( 'WP_MAX_MEMORY_LIMIT', '256M' );
define( 'WP_MEMORY_LIMIT', '128M' );

After adding the code you can confirm that the memory was changed correctly from WPML > Support > WordPress > Memory limit.

Look forward to your reply.
Thanks

November 16, 2023 at 8:23 am #14822725

patriciaS-18

Hello,

Thanks for that complete answer!
I found that piece of code before your answer on this support ticket 🙂

I tried it already and indeed the field now appears in the translation editor.

However, is it possible to make WPML translate the content of a post meta containing the ID of a custom post type to the ID of that translated post automatically by using something like this in wpml_config.xml (like for shortcodes) :

<custom-field action="translate" type="post-ids" subtype="sponsor" label="Sponsor">_sponsors</custom-field>

... Or the only way is using the wpml_tm_job_field_is_translatable hook and check the field name to replace values on the fly with wpml_object_id ?

Thanks for your help.

November 16, 2023 at 10:39 am #14824495

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Yes, you are correct. I'm afraid that there isn't a way to auto adjust ID in the field value. The type "post-ids" is used for the Gutenberg block configuration code.

For the field value, if you translate the ID number in the translation editor, no need to use the filter hook "wpml_object_id". If you don't translate the ID number, you can use the filter hook to get the translation post ID in the current language.

Or you can consider saving the post permalink as the field value, then WPML can adjust the internal link automatically.

<wpml-config>
  <custom-fields>
    <custom-field action="translate" translate_link_target="1">name_of_the_acf_field</custom-field>
  </custom-fields>
</wpml-config>

Refer documentation
https://wpml.org/documentation/support/language-configuration-files/
https://wpml.org/wpml-hook/wpml_object_id/

I hope I was helpful. Don't hesitate to ask if you find any problem along the way, I'll gladly help you.

The topic ‘[Closed] trying to get WPML to translate IDs stored in the postmeta table’ is closed to new replies.