3

In my Wordpress + Polylang website, accueil is the page name of homepage in French and inicio is the page name of homepage in Spanish.

So the homepages are:

English : https://www.example.com
French  : https://www.example.com/fr/accueil/
Spanish : https://www.example.com/es/inicio/

Is it possible to get the homepage url of a selected language?

I use home_url() to get the homepage.

And I use pll_current_language() polylang function to get the selected polylang language code of the website.

But home_url() returns same English homepage url even if I select any other language.

Computer User
  • 2,839
  • 4
  • 47
  • 69

1 Answers1

7

You can use pll_home_url() as for docs. It accepts an argument (the language for the desired homepage).

(string) pll_home_url(  $lang = '' );
Raffobaffo
  • 2,806
  • 9
  • 22