Skip Navigation

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

Problem:
The client is experiencing issues with WPML on their site. Specifically, the translated values of custom fields are not showing in the default WordPress editor, despite being set to translate in the settings. Additionally, shortcodes registered in WPML > Settings > Custom XML Configuration are not automatically translated.
Solution:
For the issue with custom fields not displaying in the default WordPress editor, we recommend checking our documentation on enabling text translation for themes not compatible with WPML, which can be found here: https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/.
Regarding the shortcodes not being automatically translated, it's important to note that our technical support primarily covers default WPML functionalities and not custom code. If these solutions do not resolve the issues or if the documentation does not cover your specific case, we highly recommend opening a new support ticket. Additionally, please check related known issues at https://wpml.org/known-issues/, verify the version of the permanent fix, and confirm that you have installed the latest versions of themes and plugins.

If further assistance is needed, please contact us through the WPML support forum: https://wpml.org/forums/forum/english-support/.

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

Last updated by Lucas Vidal de Andrade 5 months, 2 weeks ago.

Assisted by: Lucas Vidal de Andrade.

Author Posts
July 18, 2024 at 6:11 pm #15974102

nathanY

Background of the issue:
I'm having some issues with WPML on our site (hidden link).

I am trying to:

1. Custom Fields: The translated values of custom fields aren't showing in the default WordPress editor, even though they are set to translate in the settings. However, the translations for the custom fields do show up in the Advanced Translation Editor.

2. Shortcodes: I've registered shortcodes in WPML > Settings > Custom XML Configuration, but they are not automatically translated. Link to a page where the issue can be seen: hidden link

hidden link

Symptoms:
Custom Fields: The translated values of custom fields aren't showing in the default WordPress editor, even though they are set to translate in the settings. However, the translations for the custom fields do show up in the Advanced Translation Editor. Shortcodes: I've registered shortcodes in WPML > Settings > Custom XML Configuration, but they are not automatically translated.

Questions:
Why aren't the translated values of custom fields showing in the default WordPress editor?
Why are the shortcodes not automatically translated even after registering them in WPML > Settings > Custom XML Configuration?

July 18, 2024 at 6:15 pm #15974111

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

Regarding issue #02: Again, can you please provide me with more details? What's the plugin, the shortcode and the XML you are using.

Please send me an example, where I can see the content that stems from the shortcode you mentioned.

I'm waiting your feedback 🙂

July 22, 2024 at 2:53 pm #15987580

nathanY

Hi Lucas,

Thank you for your response. Below is the detailed information regarding the shortcode issues we are experiencing (both are used in homepage: hidden link).

1. We are using the [best_products_grid] shortcode here in our homepage : hidden link.

2. We are also using the [case_studies_grid] shortcode, here: hidden link.
Here is the code for the [best_products_grid] shortcode:

function best_products_grid($atts) {
?>
<div class="best_products-wrapper" id="best_products_content">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => "ASC"
);
$query = new WP_Query($args);
if ($query->have_posts()) :
while ($query->have_posts()) : $query->the_post();
$isBestSeller = get_field("add_to_best_seller", get_the_ID());
if ($isBestSeller) {
$pageUrl = get_permalink();
$product_icon = get_field("product_icon", get_the_ID());
$prependTitle = "";
$custom_page_settings = get_field("custom_page_settings", get_the_ID());
if ($custom_page_settings['enable_custom_page_settings']) {
if ($custom_page_settings['custom_url']) {
$pageUrl = $custom_page_settings['custom_url']["url"];
}
$prependTitle = "<span style='font-weight:300;'>" . $custom_page_settings['title_prepend'] . "</span>";
$additional_icon = $custom_page_settings['additional_icon'];
}
?>
" class="product-item">

';
}
?>


';
}
?>
', ' '); echo $prependTitle; ?>
</h5>
<div class="desc"><?php the_excerpt(); ?></div>


<?php
}
endwhile;
endif;
wp_reset_postdata();
?>
</div>
<?php
}
add_shortcode('best_products_grid', 'best_products_grid');
function bestProducts_ajax() {
$search_str = $_POST['search_str'];
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
's' => $search_str
);
$query = new WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) : $query->the_post();
$isBestSeller = get_field("add_to_best_seller", get_the_ID());
if ($isBestSeller) {
$pageUrl = get_permalink();
$product_icon = get_field("product_icon", get_the_ID());
$prependTitle = "";
$custom_page_settings = get_field("custom_page_settings", get_the_ID());
if ($custom_page_settings['enable_custom_page_settings']) {
if ($custom_page_settings['custom_url']) {
$pageUrl = $custom_page_settings['custom_url']["url"];
}
$prependTitle = "<span style='font-weight:300;'>" . $custom_page_settings['title_prepend'] . "</span>";
$additional_icon = $custom_page_settings['additional_icon'];
}
?>
" class="product-item">

';
}
?>


';
}
?>
', ' '); echo $prependTitle; ?>
</h5>
<div class="desc"><?php the_excerpt(); ?></div>


<?php
}
endwhile;
}
wp_reset_postdata();
die();
}
add_action('wp_ajax_nopriv_bestProducts_ajax', 'bestProducts_ajax');
add_action('wp_ajax_bestProducts_ajax', 'bestProducts_ajax');
And here is the code for the [case_studies_grid] shortcode:
function case_studies_grid() {
$case_study_button_text = get_field('button_label', 'option');
$case_studies = get_field('case_studies', 'option');
if (have_rows('case_studies', 'option')) : ?>
<div id="case_studies">
<?php while (have_rows('case_studies', 'option')) : the_row();
$image = get_sub_field('case_image');
?>
<div class="case_item">
<div class="wrapper">
<div class="case-study-image">
<img src="<?php echo $image["url"]; ?>" alt="<?php echo $image["alt"]; ?>">
</div>
<div class="case-study-text">
<h4><?php echo get_sub_field('case_title'); ?></h4>
<p><?php echo get_sub_field('case_description'); ?></p>
" target="_blank" class="elementor-button">
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<?php endif;
}
add_shortcode('case_studies_grid', 'case_studies_grid');

Please let me know if you need any more details or if there's anything else I can provide to help resolve this issue.

Thanks!

July 22, 2024 at 2:54 pm #15987583

nathanY

I have attached 2 screenshots here for you as well

hidden link
hidden link

July 22, 2024 at 5:44 pm #15988289

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hallo,

Ihr Code registriert die Texte nicht für die Übersetzung. Es sind einige Änderungen erforderlich, damit der Text vollständig übersetzbar ist. Diese Dokumentation könnte Ihnen helfen:
https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/

Da wir im WPML-Support technische Probleme im Zusammenhang mit den Standardfunktionen von WPML betreuen, können wir leider keine benutzerdefinierten Codes implementieren. Als Alternativen habe ich zwei Optionen:

Unser Netzwerk von Auftragnehmern, die Ihnen gegen eine Gebühr bei der Implementierung Ihres benutzerdefinierten Codes helfen können:
https://wpml.org/contractors/

Oder Sie verwenden eines der Plugins aus unserer Kompatibilitätsliste, um das gleiche oder ein ähnliches Ergebnis zu erzielen:
https://wpml.org/documentation/plugins-compatibility./

Ich denke, die zweite Option ist die praktikabelste.

July 23, 2024 at 1:09 pm #15992537

nathanY

Hi Lucas,
Thank you for your guidance. I have updated the shortcodes to ensure the text is fully translatable and secure. Here are the updated codes:
[case_studies_grid] shortcode:

function case_studies_grid() {
// Get the button label and case studies from the options page
$case_study_button_text = get_field('button_label', 'option');
$case_studies = get_field('case_studies', 'option');
if (have_rows('case_studies', 'option')) : ?>
<div id="case_studies">
<?php while (have_rows('case_studies', 'option')) : the_row();
$image = get_sub_field('case_image');
?>
<div class="case_item">
<div class="wrapper">
<div class="case-study-image">
<img src="<?php echo esc_url($image["url"]); ?>" alt="<?php echo esc_attr($image["alt"]); ?>">
</div>
<div class="case-study-text">
<h4><?php echo esc_html(get_sub_field('case_title')); ?></h4>
<p><?php echo esc_html(get_sub_field('case_description')); ?></p>
" target="_blank" class="elementor-button">
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<?php endif;
}
add_shortcode('case_studies_grid', 'case_studies_grid');
[best_products_grid] shortcode:
function best_products_grid($atts) {
?>
<div class="best_products-wrapper" id="best_products_content">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => "ASC"
);
$query = new WP_Query($args);
if ($query->have_posts()) :
while ($query->have_posts()) : $query->the_post();
$isBestSeller = get_field("add_to_best_seller", get_the_ID());
if ($isBestSeller) {
$pageUrl = get_permalink();
$product_icon = get_field("product_icon", get_the_ID());
$prependTitle = "";
$custom_page_settings = get_field("custom_page_settings", get_the_ID());
if ($custom_page_settings['enable_custom_page_settings']) {
if ($custom_page_settings['custom_url']) {
$pageUrl = $custom_page_settings['custom_url']["url"];
}
$prependTitle = "<span style='font-weight:300;'>" . esc_html($custom_page_settings['title_prepend']) . "</span>";
$additional_icon = $custom_page_settings['additional_icon'];
}
?>
" class="product-item">

';
}
?>


';
}
?>
', ' ');
echo $prependTitle; ?>
</h5>
<div class="desc"><?php the_excerpt(); ?></div>


<?php
}
endwhile;
endif;
wp_reset_postdata(); ?>
</div>
<?php
}
add_shortcode('best_products_grid', 'best_products_grid');
function bestProducts_ajax() {
$search_str = sanitize_text_field($_POST['search_str']);
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
's' => $search_str
);
$query = new WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) : $query->the_post();
$isBestSeller = get_field("add_to_best_seller", get_the_ID());
if ($isBestSeller) {
$pageUrl = get_permalink();
$product_icon = get_field("product_icon", get_the_ID());
$prependTitle = "";
$custom_page_settings = get_field("custom_page_settings", get_the_ID());
if ($custom_page_settings['enable_custom_page_settings']) {
if ($custom_page_settings['custom_url']) {
$pageUrl = $custom_page_settings['custom_url']["url"];
}
$prependTitle = "<span style='font-weight:300;'>" . esc_html($custom_page_settings['title_prepend']) . "</span>";
$additional_icon = $custom_page_settings['additional_icon'];
}
?>
" class="product-item">

';
}
?>


';
}
?>
', ' ');
echo $prependTitle; ?>
</h5>
<div class="desc"><?php the_excerpt(); ?></div>


<?php
}
endwhile;
}
wp_reset_postdata();
die();
}
add_action('wp_ajax_nopriv_bestProducts_ajax', 'bestProducts_ajax');
add_action('wp_ajax_bestProducts_ajax', 'bestProducts_ajax');

After these changes, I'm still not seeing translated values for the shortcode. Please let me know if you need any more details or if there's anything else I can provide to help resolve this issue.

July 23, 2024 at 1:23 pm #15992554

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

Unfortunately, as I already said, the implementation of custom code is outside the scope of this Forum. I cannot help you directly with that code.

Again, I'll send our documentation. This link might be useful:
https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/

Besides that, and the other options I sent previously, there's nothing we can do in the Forums. Again, the technical support is aimed at default WPML functionalities and not for custom code.