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.
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:
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
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.
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 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
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.
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.
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 ?
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.
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