Skip Navigation

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

Problem:
You have a WooCommerce website with several thousand products and want to automatically translate all product details except the product titles, but there is no default option available to exclude product titles from translation.
Solution:
We currently do not have a built-in feature to exclude product titles from automatic translation. However, we can offer a custom code solution. You can add the following code to your site to exclude the product titles from being translated:

add_filter('wpml_tm_job_field_is_translatable', 'testfield', 10, 2);<br />function testfield($is_translatable, $job_translate){<br />    global $wpdb;<br />    $postid = $wpdb->get_var( $wpdb->prepare("SELECT `field_data` FROM `wp_icl_translate` WHERE `field_type` = 'original_id' AND `job_id` = %d", $job_translate["job_id"] ));<br />    $posttype = get_post_type($postid);<br />    if ($job_translate["field_type"] == "title" && $posttype == "product") {<br />      return false;<br />    } else {<br />      return true;<br />    }<br />}

Please note that this solution might become outdated or may not apply to your specific case. If this does not resolve your issue or if you have further questions, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If needed, do not hesitate to open a new support ticket at WPML support forum for further assistance.

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

Last updated by Lauren 2 years, 4 months ago.

Assisted by: Lauren.

Author Posts
January 18, 2023 at 7:49 pm #12846051

George K

we have a Woocommerce website with a few thousand products. We are interested to automatically translate all products, but we want to exclude product titles. I have seen that there is no option for this. Do you have any function or script, which can exclude product names from translation?

Solution: We do not have a script to remove product titles from automatic translation. That would require custom programming.

January 24, 2023 at 4:13 pm #12883769

Lauren
WPML Supporter since 10/2015

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

This has been escalated to a feature request and ultimately will be up to our developers to decide if or when to implement this request. We include all updates in our changelog when new versions are released.

February 16, 2023 at 6:37 pm #13051837

Lauren
WPML Supporter since 10/2015

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Our developers are not planning to implement this as a feature, but they did come up with a workaround that you can use. Please see the following code that you can add to your site to exlcude the title:

add_filter('wpml_tm_job_field_is_translatable', 'testfield', 10, 2);
function testfield($is_translatable, $job_translate){
    global $wpdb;
    $postid = $wpdb->get_var( $wpdb->prepare("SELECT `field_data` FROM `wp_icl_translate` WHERE `field_type` = 'original_id' AND `job_id` = %d", $job_translate["job_id"] ));
    $posttype = get_post_type($postid);
    if ($job_translate["field_type"] == "title" && $posttype == "product") {
      return false;
    } else {
      return true;
    }
}