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, 8 months ago.

Assisted by: Christopher Amirian.

Author Posts
February 19, 2024 at 5:04 pm #15319637

amiro-4

HI
I have clarified all the issues through this video :
hidden link
Please reach me if you need further details.

February 20, 2024 at 6:41 am #15320649

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

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

Hi there,

You requirement is a little bit tricky as WPML can not show a part as translated and the other part to copy only the content.

So my guess is that you will not be able to do it automatically.

But let's go over each option one by one:

Top Image:

It might be able to copy that image if you search for it by going to WordPress Dashboard > WPML > Settings > Custom Field Translation

At the top right section of the table you will see an option to search. Please search for "image" or "banner" or whatever word that you think it is relevant for Classified pro top banner.

The result might show the custom field in question tat is responsible for showing the top banner, and set the translation option for that to "COPY".

Sidebar Custom Fields:

Please do the same for the sidebar custom fields.

The content itself:

There are a few options that you can use to show the content of the listing in other language.

The only one that will be automatic is to set the middle option in WordPress Dashboard > WPML > Settings > Post types Translation section. You need to search for the post name that classified plugin uses. It might be listing, or ad or something like that.

Select the middle option for translation for that post type.

If it does not work, then I am afraid you will need to use the Duplicate option and it will not be automatic. But you can do it in bulk.

All the options and abilities that WPML has are described here regarding duplication:

https://wpml.org/documentation/translating-your-contents/displaying-untranslated-content-on-pages-in-secondary-languages/

Thanks.

February 20, 2024 at 9:14 am #15321116

amiro-4

Thanks for your reply.I started to check the first point which is not "Top Image " as you stated , it is the listing image.I searched as you described but I did not found any relevant field.
Thanks

February 21, 2024 at 11:15 am #15327306

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

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

Hi there,

Please follow the steps mentioned for the copying of the listing and see if it works for you, If not, I'd appreciate it if you could give me the URL/User/Pass of your WordPress dashboard after you make sure that you have a backup of your website.
It is absolutely important that you give us a guarantee that you have a backup so if something happens you will have a point of restore.

Make sure you set the next reply as private.

February 21, 2024 at 4:31 pm #15329386

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

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

Hi there,

Thank you I took a look into the issue and could not also find a way to copy the image with the second option of the custom post type translation method in WPML settings.

I'm afraid you will not be able to do the duplication automatically, and you need to do it yourself by going to WPML > Translation Management,

Selecting the listing in question and at the bottom selecting the "Duplicate content" option and clicking the blue button.

Thanks.

February 21, 2024 at 4:35 pm #15329389

amiro-4

Thanks for your reply.What about the custom fields of each listing like land size for Lands listing type, even after doing manual duplication or translation they are not showing?
Regards

February 22, 2024 at 12:35 pm #15333553

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

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

Hi there,

Thank you. I tried to check the Land size and unfortunately that field does not show even if I do the translation of it in classic translation editor.

I'd appreciate it if you could install the Duplicator or All in one migration plugin and create a copy of the website which I can use to report this to the compatibility team.

I tried to install myself but it says "Invalid Archive".

One more thing I suggest that you do is to report this to the classified pro plugin support too. The reason behind that is, the multilingual compatibility is maintained by the plugin developers and not us.

That way you will attack the issue from both sides.

Thanks.

February 24, 2024 at 11:21 am #15340225

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

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

Hi there,

Thank you. The issue is reported to the second tier support and I will get back to you as soon as I have an answer.

It might take time.

Thanks.

February 24, 2024 at 1:23 pm #15340414

amiro-4

Hi
Ok noted, thanks.
Best Regards

February 27, 2024 at 3:41 pm #15349934

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 which I'd appreciate it if you can perform first on a staging website and see if it works ok. Make sure you have a backup before the steps.

here are two custom field posts rtcl_cf for fields and rtcl_cfg for collection of fields kind of group.

In the customer website both of these CPT set to display as translated but in the original config file in Classified Listing Pro rtcl_cf set to translatable and rtcl_cfg to do not translate.

I would recommend this setting only to avoid compatibility issues.

However, this still does not work after changing the settings to I had to follow these steps after insepcting DB and plugin code.

Set rtcl_cf to transtable.
Set rtcl_cfg to do not translate.
Run this query to clear the invalid records from WPML table

DELETE FROM `wp_icl_translations` WHERE `element_type` = 'post_rtcl_cfg';

Now due to this incorrect setting custom fields rtcl_cf missing the parent post rtcl_cfg in DB to fix this we need to translate the fields again. So go to Classified Listing > Multilingual. Find land fields and delete the translation. Then translate the land field again.
After translation we can see the custom field on translated Listing.

Kindly get back to us with the result.

March 2, 2024 at 8:44 am #15365422

amiro-4

Hi, the custom fields translation issue is resolved now but the issue that while trying bulk duplication, they are not duplicated, is there any way to do that ?

March 3, 2024 at 1:37 pm #15366721

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

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

Hi there,

Thanks, I informed the second-tier support and asked about the bulk translation and will get back to you as soon as I have an answer.

Thank you.

March 5, 2024 at 4:36 pm #15375649

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

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

Hi there,

The second tier asks for this and I'd appreciate it if you can help me understand which is the issue:

I tested the bulk duplication on the local copy of the site and the fields are there. Just the values are not there e.g.
Do you mean the values are not there or the entire fields are missing?

[check the attached screenshot]

I am asking because the results are same when duplicating from edit screen. So I am not sure what is fixed and what is not fixed.

image.png
March 13, 2024 at 12:59 pm #15404069

amiro-4

I mean The field names and values.Please ask him to use the staging website called "choufly staging".In that version the Classified Ad pro team said they resolved the fields and their values not showing issue.He can create an ad in the Properties>Plot and lands section and they try to bulk duplicate it to ar and fr.
Regards

March 13, 2024 at 3:45 pm #15405189

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

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

Hi there,

I am a little bit confused. So the issue is fixed by the developers?

If yes, then is there something needed from our side?