WP STAGING and WPML Configuration

Use a multilingual plugin like WPML, Weglott, Polyglot, or another, and you set up the language settings to use custom folders with the language code, e.g., yourdomain.com/en/. You may encounter an issue where opening a page on a staging site results in error 404. That can happen if the staging site permalinks are disabled.

There are three available solutions:

Create the staging site in a subdomain

You can clone your WordPress website to a subdomain. If you do this, you will no longer encounter any link structure issues, as the URL structure mimics the URL structure on the production website.

Change WPML language URL format.

You can switch the WPML language settings on your WP Staging staging site to URL-based language like yourdomain.com/?lang=en

You can change this under WPML > Languages.

Note: If you push the staging site back to live, you must revert this setting on the live site.

Activate Post Name Permalinks.

You can try to activate post name permalinks on the staging site by following this article.

Creating a Staging Site with Different Domains per Language

Let’s say you have a live site with the “example.com” domain for the English version, “example.fr” for the French and “example.de” for the German, and You want to create clones of the sites to staging.example.com, staging.example.fr and staging.example.de.

What you need to do is to use this code snippet as mu-plugin: (Of course, it must be modified to adapt to your domains):

function wpstg_cloning_custom_params($args)
      $args['search_for'] = array_merge(
         ['example.fr', 'example.fr']

      $args['replace_with'] = array_merge(
         ['staging.example.fr', 'staging.example.de']

      return $args;

add_filter('wpstg_clone_searchreplace_params', 'wpstg_cloning_custom_params'); 

Then, create your staging site normally on the subdomain “staging.example.com” following this guide. Of course, the subdomain must be created via your hosting control panel first.

Also, don’t forget to point these new subdomains (staging.example.fr, staging.example.de) to the main staging site’s IP via the domain’s DNS manager.

WPML Troubleshooting Options

After pushing or cloning your WordPress site with WP Staging, the WPML translations might not work as intended. The internal cache handling of WPML often causes that. Gladly WPML offers you a few powerful troubleshooting options that you can access to purge and refresh the WPML cache.

The information on this page is for advanced WPML users. If you are unsure what to do, please contact the WML support before executing any WPML troubleshooting options.

You can open the WPML troubleshooting page from WPML > Support.
Click the link for troubleshooting.

How to access the WPML troubleshooting options
How to access the WPML troubleshooting options 

Create a WordPress website backup before executing any listed action from that options page.

The WPML troubleshooting options page
The WPML troubleshooting options page

In the table below, you see a description of the most important commands and possible use-case scenarios:

Command When to use it
Clear the Cache in WPML
  • If an assignment of a translation is not working.
  • If you have string-related database deadlocks.
  • If the strings are not appearing and you get an error such as “WordPress database error Deadlock found when trying to get lock”. This happens mostly after migration from the local development environment to production. Also, try restarting the transaction for the INSERT IGNORE INTO query.
  • Language switcher issues.
Remove ghost entries from the translation tables
  • Remove entries from the WPML table if they are not linked properly after upgrades or bug fixes.
  • Removing unused strings.
  • When receiving errors during the process of moving the products with Draft status to trash.
Fix element_type collation
  • Use if the translated content is missing after translation.
  • Use to fix the errors such as: “post_type is X but collation is Y”.
  • If you cannot see a list of posts or pages after installing the WPML.
  • Products are not listed for translation in WooCommerce.
Fix WPML table collation
  • If you get errors related to the illegal mix of collations. For example, if you get the “WordPress database error Illegal mix of collations utf8_general/utf8mb4” error.
Set language information
  • If you have created content while WPML was inactive, or if other plugins create content and bypass the WordPress API, this content may not have language information and will not display for any language. This action will solve the problem.
  • If the translated posts are not connected to the original.
Cleanup and optimize string tables
  • Use only if you have a site that was translated with WPML prior to version 4.3. Using this command will remove the content of the strings cache table (_icl_strings_url and _icl_strings_pages) and it will optimize the icl_strings table. It will only work when all the MO files are correctly created. In other situations, you will be able to click the button but no action will be triggered. If the button is not working go to the WPML → Theme and plugins localization page and scan the themes and plugins for missing MO files.


Related Articles

Updated on January 30, 2024