Skip to content Skip to sidebar

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

Problem:
If you're experiencing database errors on your translation dashboard with WPML when using a custom database prefix (not the default "wp_") and your site supports 30 or more languages, this might be due to hard-coded database prefixes in the WPML plugin code.
Solution:
First, ensure you have a full backup of your site. Then, navigate to the following files and make the specified changes:

/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/wpml/src/Infrastructure/WordPress/Component/Item/Application/Query/SearchQuery/QueryBuilder/ManyLanguagesStrategy/SearchQueryBuilder.php

Replace:

LEFT JOIN wp_icl_translations target_t ON target_t.trid = source_t.trid AND target_t.language_code IN ({$gluedEscapedLanguageCodes})<br />LEFT JOIN wp_icl_translation_status target_ts ON target_ts.translation_id = target_t.translation_id

With:

LEFT JOIN {$this->queryPrepare->prefix()}icl_translations target_t ON target_t.trid = source_t.trid AND target_t.language_code IN ({$gluedEscapedLanguageCodes})<br />LEFT JOIN {$this->queryPrepare->prefix()}icl_translation_status target_ts ON target_ts.translation_id = target_t.translation_id

Apply the same changes in:

/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/wpml/src/Infrastructure/WordPress/Component/Item/Application/Query/SearchQuery/QueryBuilder/ManyLanguagesStrategy/SearchPopulatedTypesQueryBuilder.php

This modification ensures that the query uses the correct custom prefix instead of the hardcoded 'wp_'.

If this solution does not resolve your issue, or if it seems outdated or irrelevant 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.

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 1 reply, has 0 voices.

Last updated by Andrey 1 month, 1 week ago.

Assisted by: Andrey.

Author Posts
July 16, 2025 at 11:24 am #17241661

jackZ-5

Background of the issue:
I have built a website using WordPress and used the WPML multilingual plugin to automatically translate all the content. However, the website is now experiencing some issues. When using WPML on a site with a custom database prefix (not the default "wp_") and 30 or more languages, you might experience a database error when visiting the translation dashboard. This occurs due to a hard-coded database prefix in the WPML plugin code. Solution: Please make sure you have a full backup of your site before proceeding. Open: /wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/wpml/src/Infrastructure/WordPress/Component/Item/Application/Query/SearchQuery/QueryBuilder/ManyLanguagesStrategy/SearchQueryBuilder.php Look for: [php] LEFT JOIN wp_icl_translations target_t ON target_t.trid = source_t.trid AND target_t.language_code IN ({$gluedEscapedLanguageCodes}) LEFT JOIN wp_icl_translation_status target_ts ON target_ts.translation_id = target_t.translation_id [/php] Replace with: [php] LEFT JOIN {$this->queryPrepare->prefix()}icl_translations target_t ON target_t.trid = source_t.trid AND target_t.language_code IN ({$gluedEscapedLanguageCodes}) LEFT JOIN {$this->queryPrepare->prefix()}icl_translation_status target_ts ON target_ts.translation_id = target_t.translation_id [/php] This change ensures that the query uses the correct custom prefix instead of the hardcoded wp_. Another place is in: /wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/wpml/src/Infrastructure/WordPress/Component/Item/Application/Query/SearchQuery/QueryBuilder/ManyLanguagesStrategy/SearchPopulatedTypesQueryBuilder.php Look for: [php] LEFT JOIN wp_icl_translations target_t ON target_t.trid = source_t.trid AND target_t.language_code IN ({$gluedEscapedLanguageCodes}) LEFT JOIN wp_icl_translation_status target_ts ON target_ts.translation_id = target_t.translation_id [/php] replace with: [php] LEFT JOIN {$this->queryPrepare->prefix()}icl_translations target_t ON target_t.trid = source_t.trid AND target_t.language_code IN ({$gluedEscapedLanguageCodes}) LEFT JOIN {$this->queryPrepare->prefix()}icl_translation_status target_ts ON target_ts.translation_id = target_t.translation_id [/php]

Symptoms:
The website is experiencing a database error when visiting the translation dashboard due to a hard-coded database prefix in the WPML plugin code.

Questions:
What should I do?
Why am I being alerted to these issues?

July 16, 2025 at 9:08 pm #17243706

Andrey
WPML Supporter since 06/2013

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+03:00)

I believe this is the same issue that was reported here:
https://wpml.org/forums/topic/i-built-my-website-using-wordpress-but-the-vietnamese-pages-translated-with-wpml-are-not-displaying/

To avoid duplication and ensure a more efficient troubleshooting process, let’s continue addressing the issue in that support ticket.