【问题标题】:Get homepage of a website of selected languge in Wordpress + Polylang在 Wordpress + Polylang 中获取所选语言网站的主页
【发布时间】:2020-07-09 10:54:47
【问题描述】:

在我的 Wordpress + Polylang 网站中,accueil 是法语主页的页面名称,inicio 是西班牙语主页的页面名称。

所以主页是:

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

是否可以获取所选语言的主页url?

我使用home_url() 获取主页。

而我使用pll_current_language()polylang函数来获取网站选择的polylang语言代码。

但home_url() 会返回相同的英文主页网址,即使我选择任何其他语言。

【问题讨论】:

    标签: php wordpress polylang


    【解决方案1】:

    您可以使用pll_home_url() 作为docs。 它接受一个参数(所需主页的语言)。

    (string) pll_home_url(  $lang = '' );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-03-07
      • 2017-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多