Skip Navigation

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

Problem:
The client wanted to know if it's possible for the main language (Armenian) to show its language code 'hy' in the URL slug, similar to how the Russian version shows 'ru'.

Solution:
We recommended adding PHP code to the client's theme to redirect the root domain to the directory of the default language. Here are the steps:
1. Create a PHP template file for the site's theme, preferably in a child theme.
2. Add the following PHP code to the new template file:

<?php<br />/*<br />Template Name: Root redirect<br />*/<br />wp_redirect( home_url() );<br />exit;

3. Edit the root page and select the newly created template from the Summary section in the right sidebar.
4. Update the page to ensure the root page now redirects to the default language directory.

For detailed instructions, please refer to our documentation on redirecting the root domain to the default language directory.

Please note that this solution might be irrelevant if it's outdated or not applicable to your case. If the issue persists, 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 you still need assistance, please open a new support ticket with us.

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.

This topic contains 8 replies, has 2 voices.

Last updated by Christopher Amirian 1 year, 3 months ago.

Assisted by: Christopher Amirian.

Author Posts
January 27, 2024 at 11:36 pm #15233423

Armen Markosyan

Tell us what you are trying to do?

HI DR WPML TEAM
T-SHOES.ONLINE

ARMENIAN LANGUAGE IS MY MAIN LANGUAGE . IN THE SLUG I DONT SEE WORD ,,HY,, SE PLS SCREENSHOT 1.
IN RUSSIAN VERSION I SEE WORD ,,RU,, WHICH I THINK IIS NORMALLY.
I WOULD LIKE KNOW CAN I IN ARMENIAN ( ITS MAIN LANGUAGE ) I ALSO SEE ,,HY,, ?
---------------------------------------------------------------------------------------------------
FRANKLY I SAW OTHER WEVSITES AND COMPARE WITH T-SHOES.ONLINE.
IN THE INTERNET I SEE BOTH VERSION
1. MAIN LANGUAGE SHOEW ,,HY,,
2 MAIN LANGUAGE DONT SHOW ANYTHING.
------------------------------------------------------------------------------------------
I PREFER OPTIOIN 1 ABOVE , WHEN MAIN LANGUAGE ALSO SHOW ,,HY,, - IS THAT POSSIBLE ?
THANK
SINCERLEY ARMEN

Screenshot_2.png
Screenshot_1.png
January 28, 2024 at 6:49 am #15233588

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Բարեւ ձեզ 🙂

Yes it is possible to have the Armanian language code added to the URL.

Please go to WordPress Dashboard > WPML > Languages >Language URL format and enable the "Use directory for default language" option there.

For more detailed information:

https://wpml.org/documentation/getting-started-guide/language-setup/directory-default-language/

Thanks.

Screenshot 2024-01-28 at 10.48.39.png
January 29, 2024 at 9:18 pm #15240898

Armen Markosyan

HI DR AMIRIAN / ԲԱՐԵՎ ՁԵԶ
THANKS FOR HELPING !!!

NOW I SEE ,,HY,,
hidden link

BUT I HAVE 1 QUESTION
SEE PLS SCREENSHOT 15
THERE APPEAR RADIO BUTTON ,, A PAGE CREATE ROOT PAGE ,, AND NOW LANGUAGE URL FORMAT LOOKS LIKE ON SCREENSHOT 15.
MY QUESTIOIN IS
,, IS THAT NORMALLY AND DO I ALL THING RIGHT ,, ???
THANKS
SINCERELY ARMEN

Screenshot_16.png
Screenshot_15.png
January 30, 2024 at 10:23 am #15242577

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

The Root page option there is for scenarios that the visitor will go to the main domain of the website For example:

hidden link

In such scenarios, it is recommended that you create a root page which will be the starting point of your website and you can add a language switcher there when the customer can decide which language to choose.

But if you do not want such a page, you can always use the method below to redirect the main domain to the URL with the default language code.

All the details are explained here:

https://wpml.org/documentation/getting-started-guide/language-setup/directory-default-language/#redirect-the-root-domain-to-the-default-language-directory

Thanks.

January 31, 2024 at 8:38 pm #15252114

Armen Markosyan

HI DR Christopher Amirian
I UNDERSTAND MEANING OF ROOT PAGE AND I DONT WANT USE IT. I WOULD LIKE REDIRECT MAIN LANGUAGE PAGE .
NOW LANGUAGE URL FORMAT LOOKS LIKE ON SCREENSHOT 3 ... I PUT THERE URL hidden link . IS THAT RIGHT ?
--------------------------------------------
I THINK NOW I HAVE SECOND PROBLEM, OR ISSUE .
IF I USE URL WITHOUT ,,HY,, THEN WEBSITE SHOW BLANK PAGE / SEE PLS SCREENSHOT 4 / - I THINK ITS NOT NORMALLY ? RIGHT ? HOW CAN I FIX IT ?
THANKS
SINCERELY ARMEN

Screenshot_4.png
Screenshot_3.png
February 3, 2024 at 2:29 pm #15262254

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi Armen,

You will need to add the PHP code mentioned in the documentation I shared, so when the domain is typed without HY it automatically redirects to HY:

Sometimes, you might want to redirect your root domain to the directory of the default language. In other words, if English is the default language and someone visits hidden link, they are redirected to hidden link.

Start by creating a PHP template for your site’s theme. In most cases, you should add such PHP files to a child theme.

Add the following content to your new PHP page template file:

<?php
/*
Template Name: Root redirect
*/
wp_redirect( home_url() );
exit;

Now, go back and edit your root page.

In the right sidebar, expand the Summary section and select the template you just created.

hidden link

When you’re done, make sure to update the page.

Now, your root page will redirect to the default language directory.

https://wpml.org/documentation/getting-started-guide/language-setup/directory-default-language/#redirect-the-root-domain-to-the-default-language-directory

Thanks.

February 6, 2024 at 9:19 pm #15273865

Armen Markosyan

HI DR AMIRIAN - THANKS FOR HELPING !!!
I CREATED ROOT PAGE BUT I CANT PUT CODE IN NEW PHP PAGE TEMPLATE BCOZ I AM NOT GOOD USER AND ASK TO HELP ME THEME SUPPORT . PLS GIVE ME 1-2 DAYS TILL THEY WILL SOLVE FOR ME ISSUE .
THANKS FOR UNDERSTANDING
SINCERELY ARMEN

February 7, 2024 at 6:29 am #15274558

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi Armen,

If you provide the login information and permission I can do that for you.

I'd appreciate it if you could give me the URL/User/Pass of your WordPress dashboard after you make sure that you have a backup of your website.
It is absolutely important that you give us a guarantee that you have a backup so if something happens you will have a point of restore.

Make sure you set the next reply as private.

Շնորհակալություն

February 14, 2024 at 11:38 am #15301805

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi Armen,

I logged in and fixed the issue.

Now if you go to the main URL of the website it will be redirected to HY automatically.

Thank you.

February 14, 2024 at 12:35 pm #15302168

Armen Markosyan

ՇԱՏ ՇՈՐՀԱԿԱԼՈՒԹՅՈՒՆ