Problem: The client has a custom post type called 'resources' with an accompanying custom Gutenberg block called 'resource feed'. This block is dynamic and displays data from entries in the feed. However, it does not display different content based on the selected language, showing the same content across all languages. Solution: We recommend using the
wpml_object_id
hook to ensure that the
$post_id
refers to the translated post in the currently active language. Here is how you can implement it:
// will return the post ID in the current language for post ID 1
echo apply_filters( 'wpml_object_id', 1, 'post' );
// will return the category ID in the current language for category ID 4. If the translation is missing it will return the original (here: category ID 4)
echo apply_filters( 'wpml_object_id', 4, 'category', TRUE );
// will return the German attachment ID for attachment ID 25. If the translation is missing it will return NULL
echo apply_filters( 'wpml_object_id', 25, 'attachment', FALSE, 'de' );
If this solution does not resolve your issue or seems outdated, 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. We highly recommend opening a new support ticket for further assistance at WPML support forum.
Problem: The client was experiencing an issue where some translated content was not displaying on the front end of a WooCommerce product page. The content was managed via the Gutenberg editor and involved a shortcode. Despite the content being visible in the Advanced Translation Editor, it was not rendered on the front end for certain tabs. Solution: We discovered that the issue was due to the [GK-TABS-BREAK] being mistakenly treated as a real shortcode during translation, which led to its duplication and subsequently broke the tab layout. To resolve this, we modified the code in the theme's shortcode file. Here are the steps we took:
Made a minor edit in the default language product to trigger a retranslation.
Completed the translation in the WPML Advanced Translation Editor.
This solution resolved the issue, and the translated content now displays correctly on the front end. However, please be aware that this fix might become irrelevant due to future updates to the theme or WPML. If you encounter similar issues or if this solution does not work for you, we 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 the problem persists, please open a new support ticket.
Problem: You want to translate the JavaScript and PHP files on your website. Solution: To make text in these files translatable, you need to register the strings with WordPress' localization functions. Here's how:
For PHP files: Wrap any user-facing text in WordPress i18n functions such as
__()
or
_e()
with your theme or plugin text domain. For example:
echo __( 'Your text here', 'theme-textdomain' );
For JavaScript files: Text hardcoded in JavaScript files cannot be translated automatically. Instead, pass strings from PHP to JavaScript using functions like
After registering, you can find these strings in WPML → String Translation, where you can provide translations for each language.
If you need further assistance or if this solution does not apply to your case, 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 the issue persists, please open a new support ticket.
Problem: The client has created a language landing page and wants the website to remember the user's language choice using cookies, so it doesn't prompt for language selection on subsequent visits. Solution: We recommend the following steps: 1. Ensure that the 'Language filtering for AJAX operations' is enabled in WPML under WPML >> Languages. This setting allows WPML to set the language code in the cookie 'wp-wpml_current_language'. 2. Use a PHP if/else statement to read this cookie and redirect the user to the correct language page based on their previous selection. For more details on handling cookies with WPML, please refer to our documentation: https://wpml.org/documentation/support/browser-cookies-stored-wpml/ https://wpml.org/documentation/getting-started-guide/language-setup/enabling-language-cookie-to-support-ajax-filtering/
Please note that this solution might be irrelevant if it's outdated or not applicable to your case. 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 this does not resolve your issue, please open a new support ticket at https://wpml.org/forums/.
Problem: The client is experiencing issues with automatic translations in WPML where the title and content remain empty. Additionally, when trying to refresh an individual post from the WPML translation editor, the page fails to load and displays a PHP Fatal error related to a 'Division by zero' in the WPML plugin files. There are also PHP warnings indicating 'Undefined array key "post_title"'. Solution: We recommend checking for any custom code that might be interfering with the WPML functionalities, especially those related to post titles in translations. It's important to ensure that all custom code snippets are correctly adjusted to match the specific custom post types used on your site. For further guidance on managing translation settings for custom post types, you can refer to this documentation: https://wpml.org/forums/topic/remove-title-from-translation-only-for-custom-post-type/#post-15269091.
If these steps do not resolve the issue, or if the solution seems outdated or not applicable to your case, 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 problems persist, please open a new support ticket with us for personalized assistance.
Problem: The client reported issues with automatic translations not detecting HTML fields in product category descriptions and some descriptions not being translated at all. Additionally, there were problems with the HTML structure not being respected in translations, which is crucial for SEO, and issues with Yoast SEO term meta not appearing translated in the frontend.
Solution: 1. To address the HTML tags issue in product category descriptions: - Edit the file
- In WPML settings, disable the option "Don't show translated taxonomies in Translation Editor" to allow translation of category descriptions directly in the Advanced Translation Editor and retranslate the products. 2. Alternatively, translate the product category manually via WPML > Taxonomy Translation. 3. For translating Yoast SEO term meta, ensure to send the term meta for translation from WPML > Translation Dashboard as detailed in our documentation here. 4. To resolve issues with the same slug across languages, enable the option "Adjust IDs for multilingual functionality" in WPML > Languages > Section Make themes work multilingual.
If these solutions do not resolve your issue or seem outdated, we recommend opening a new support ticket. Additionally, 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. For further assistance, please visit our support forum at WPML support forum.
Problem: The client is experiencing an issue where after switching from the Linguise language plugin to WPML, the URL slug for Portuguese changed from 'pt' to 'pt-pt', and they want to revert it back to the original 'pt' slug. Solution: If you're experiencing this issue, we recommend creating a custom language in WPML where you can specify the desired language code. Here's how you can do it: 1. Go to WPML > Languages. 2. Under 'Edit Languages', click on 'Add languages'. 3. Enter the language name, code (in this case, 'pt'), and other details. 4. Save your changes. This should help you set the URL slug to your preferred format.
Please note that this solution might be irrelevant if it's outdated or not applicable to your case. 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 the issue persists, please open a new support ticket at WPML support forum for further assistance.
Problem: Клиент столкнулся с проблемой синхронизации остатков товаров в WooCommerce при использовании WPML и обновлении stock через внешний источник. Остатки корректно обновляются только у товара на основном языке, в то время как переводы товара не получают обновление _stock и _stock_status и остаются со статусом «Нет в наличии». Solution: Мы объяснили, что WPML не может автоматически определить обновление остатков через внешний источник. Для ручной синхронизации остатков можно использовать панель управления WordPress: WooCommerce → WPML Multilingual & Multicurrency for WooCommerce → Status → Troubleshooting и выбрать опцию “Synchronize stock for products and product variations”. Для программной синхронизации можно использовать хуки WPML:
для синхронизации конкретного поля или wpml_sync_all_custom_fields для синхронизации всех пользовательских полей конкретного товара.
Если данное решение не актуально или не помогает в вашем случае, рекомендуем открыть новый тикет в службе поддержки WPML. Также рекомендуем проверить известные проблемы, версию постоянного исправления и убедиться, что у вас установлены последние версии тем и плагинов.