Skip navigation

Эта тема содержит 0 ответов, имеет 1 голос.

Последнее обновление: nathanY 2 месяца, 2 недели назад.

При содействии: Lucas Vidal de Andrade.

Автор Записи
23 октября, 2024 на 1:03 пп #16321930

nathanY

Background of the issue:
I am currently using WPML on my WordPress site, which includes a custom post type called products. My goal is to prevent specific product titles from being translated across the entire site. I have added the following code to my theme's functions.php file: get_var($wpdb->prepare("SELECT `field_data` FROM `wp_icl_translate` WHERE `field_type` = 'original_id' AND `job_id` = %d", $job_translate["job_id"])); // Check the post type $posttype = get_post_type($postid); // If the post type is 'products', exclude the title from translation if ($job_translate["field_type"] == "title" && $posttype == "products") { return false; // do not translate the title } // Default behavior return $is_translatable; } ?>

Symptoms:
Despite the above implementation, the product titles are still being translated by WPML, which is contrary to my requirements.

Questions:
Could you please assist me in troubleshooting this issue?
Are there alternative methods or settings that need to be configured to exclude product titles from being translated?