This tutorial explains how to set up languages in different domains (or subdomains) in a multisite install. Please read carefully, as you will need to replace a file to complete the setup.
WPML offers support for setting up WPML to be using the ‘different domain per language’ option for the language url format when using WordPress in the multisite mode. This was not possible before this version since the implementation required a special set up involving a drop-in plugin.
This can only be accomplished by using a drop-in plugin. The difference from the regular plugins is that this one will load earlier in the WordPress execution, before the url is resolved to a specific site.
sunrise.php is a drop-in and it works by being placed in the
wp-content folder and enabling it in
Setting this up is a two steps process described below.
- Append content of the file
wp-content/sunrise.phpfile. Make sure it will be executed (e.g. will not be places after a
- Make sure that you have the line below in
If you need to change the value to
onmake sure that you don’t enable functionality that you do not want in your existing (but inactive)
- Copy the file
- Add the line below in
First, make sure that your domains have the correct DNS set and they point to the same folder as the domain of the default language.
Under WPML » Languages » Language URL format select ‘A different domain per language’ and fill in the corresponding urls and then click ‘Apply’
If you get an error message (Data not saved), try saving again with the ‘Validate on save’ boxes unchecked.
This feature is only available starting with WPML 2.8 and the
sunrise.php file can be obtain from the Sitepress Multilingual CMS plugin:
sunrise.php drop-in filters the query that WordPress uses for resolving the domain used in the url of the request and compares it to the list of associated domains of each site installed. It does this by checking each site until it finds a match. The domains used for the secondary languages are not present in the
wp_site tables but in the
icl_sitepress_settings value in
wp_options for each site.
A drop-in was required because this happens before the
plugins_loaded hook is fired and before any regular plugin can add any filter or perform any actions.
Besides setting the sunrise.php file, as described in this tutorial, you should also create the DNS entries for all domains and point them all to the same WordPress install. For instructions, follow the FAQ entry on server settings for languages in domains.
- Make sure that the drop-in script is being loaded and executed. e.g.
- Check if another drop-in plugin is preventing execution of the one indicated here.
- Make sure that you’ve set up the DNS to point all domains to your multisite WordPress install.
- Make sure that you’ve set up Apache (or your web server) to respond to all domains for your multisite WordPress install.
- For issues with your language switcher, make sure to install our WPML-MU-Domain-Mapping bridge plugin.