Skip to content Skip to sidebar

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

Problem:

Classified Listing Pro, Listing translation of the custom field not working when using the duplicate feature of WPML

Solution:

Please add the code below to the functions.php file of your theme:

/**
 * Translate ID of in meta key for Classified Listing Pro custom field when duplicating.
 * 
 * @link wpmlsupp-11480
 */
add_action('icl_make_duplicate', function ($master_post_id, $lang, $post_array, $id) {
    global $wpdb;
 
    $all_rtcl_cf = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta where post_id = $master_post_id AND meta_key LIKE '\_field\_%'");
 
    if (!empty($all_rtcl_cf)) {
        foreach ($all_rtcl_cf as $meta_obj) {
            $meta_key_arr = explode('_', $meta_obj->meta_key);
            $rtcl_cf_id = apply_filters('wpml_object_id', $meta_key_arr[2], 'rtcl_cf', true, $lang);
 
            if (is_int($rtcl_cf_id) && $rtcl_cf_id !== $meta_key_arr[2]) {
                delete_post_meta($id, $meta_obj->meta_key);
                update_post_meta($id, '_field_' . $rtcl_cf_id, maybe_unserialize($meta_obj->meta_value));
            }
        }
    }
}, 10, 4);

We also are going to communicate with the plugin developer to add the code above or an implementation of it to their multilingual plugin.

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

Last updated by Itamar 1 year, 7 months ago.

Assisted by: Christopher Amirian.

Author Posts
March 16, 2024 at 12:18 pm #15416713

amiro-4

The issue of the custom fields and their values which were not showing in translated content, is fixed by the plugin developers now when I translate a listing manually I can see all fields. The requested thing from your side is the bulk translation, when I perform it , the custom fields and their values are not translated.If you are still confused , I can make a video to explain to you.

March 18, 2024 at 10:45 am #15420394

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

And thank you for the video.

I added the video for the second tier support and will get back to you as soon as I have an answer.

March 19, 2024 at 1:12 pm #15426510

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

I have an answer from the second tier support:

Please add the code below to the functions.php file of your theme:

/**
 * Translate ID of in meta key for Classified Listing Pro custom field when duplicating.
 * 
 * @link wpmlsupp-11480
 */
add_action('icl_make_duplicate', function ($master_post_id, $lang, $post_array, $id) {
	global $wpdb;

	$all_rtcl_cf = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta where post_id = $master_post_id AND meta_key LIKE '\_field\_%'");

	if (!empty($all_rtcl_cf)) {
		foreach ($all_rtcl_cf as $meta_obj) {
			$meta_key_arr = explode('_', $meta_obj->meta_key);
			$rtcl_cf_id = apply_filters('wpml_object_id', $meta_key_arr[2], 'rtcl_cf', true, $lang);

			if (is_int($rtcl_cf_id) && $rtcl_cf_id !== $meta_key_arr[2]) {
				delete_post_meta($id, $meta_obj->meta_key);
				update_post_meta($id, '_field_' . $rtcl_cf_id, maybe_unserialize($meta_obj->meta_value));
			}
		}
	}
}, 10, 4);

We also are going to communicate with the plugin developer to add the code above or an implementation of it to their multilingual plugin.

Thanks.

March 23, 2024 at 7:25 am #15442788

amiro-4

It is working fine thanks. You can close the ticket , no need for further assistance.

March 23, 2024 at 7:43 am #15442804

Itamar
WPML Supporter since 02/2016

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi,

I'm writing here in the name of Christopher, my colleague.

Christopher is on vacation now.
I'm glad that things work out well.

We're closing this ticket.

Don't hesitate to contact us again with any WPML issues or questions.

Regards,
Itamar.