Set default language directory as root page in wpml

I will address setting the default language as root page using WPML. The first part will explain how the plugin handles multiple languages for a bit, if you are just interested in the solution scroll to the bottom of this article.

I have been building bi-lingual websites for a while, mainly with the help of the WPML plugin. It’s an awesome plugin that saves me a lot of the hassle required to build a multi-lingual websites.

WPML provides three ways to display your website’s languages:

  1. Each language in it’s own directory ex: (recommended)
  2. Different domain per language ex:
  3. Add language name as a URL parameter ex:

I have always used (and recommend) the first option.

It gives you the option to use or not use a directory for the default language, let’s say we have an English and Arabic website and English is the default language, you can have it like and

Or you choose not to use directory for the home page so it’s just the domain for the default language But I prefer to have a directory for the default language as well, that way it’s more convenient for the user.

Having a directory for each language raises the question of what to show in the root domain, without the language directory. WPML gives us the two options:

  1. A root page.
  2. Static HTML file.

The root page

This is a regular WordPress page that WPML will display when a user visits the root URL of your website, you may use it as a landing page that makes the user choose what languages does he/she want’s to visit.

Static HTML file

The same as the root page but using an HTML file on the server, instead of a WordPress page.

default language as root page

I wanted to have a directory for each language but at the same time, didn’t want to display a root page nor a static html file for the root URL. Instead, I wanted the root URL to redirect to the default language directory so when a user visits it automatically redirects to

There is no way to do so through WPML settings but we are able to do so using a custom WPML/Wordpress function, just copy the following snippet and paste it anywhere in your functions.php file

Now visit the root of your website and it should redirect to the default language.

If you have anything to add, let us know in the comments.

3 responses to “Set default language directory as root page in wpml”

  1. tobiv says:

    I had to set it to Root Page and just created an empty page. Work perfectly, thanks!

  2. tobiv says:

    I added it as a plugin by the way, makes it easier to reuse on the next project.

Leave a Reply