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.
This topic contains 19 replies, has 3 voices.
Last updated by 1 year, 7 months ago.
Assisted by: Christopher Amirian.







