网站优化

网站优化

Products

当前位置:首页 > 网站优化 >

使用Polylang插件在Wordpress网站上切换不同语言的页脚

GG网络技术分享 2025-03-18 16:12 10


问题描述:

Wordpress Polylang plugin doesn\'t seem to translate my footer widgets. So I was thinking about creating separate footers for the different languages and calling the correct footer via a function in my child themes functions.php that checks the page language like so:

function switch_footer_language() {

if(pll_current_language==\'th\') {

get_footer(\'footer_th.php\');

} elseif(pll_current_language==\'en\') {

get_footer(\'footer_en.php\');

}

}

Would this work? Would this be an appropriate way to do this? Is there a better way? And if so how?

Many Thanks.

图片转代码服务由CSDN问答提供

感谢您的意见,我们尽快改进~

功能建议

Wordpress Polylang插件似乎不会翻译我的页脚小部件。 所以我正在考虑为不同的语言创建单独的页脚,并通过我的子主题functions.php中的函数调用正确的页脚,它检查页面语言如下:</ p>

  function  switch_footer_language(){

if(pll_current_language ==\'th\'){

get_footer(\'footer_th.php\');

} elseif(pll_current_language ==\'en\'){

get_footer(\'footer_en.php \');

}

}

</ code> </ pre>

这会有效吗? 这是一个合适的方法吗? 有没有更好的办法? 如果是这样的话?</ p>

非常感谢。</ p>

</ div>

网友观点:

Worked this out myself. Simply add multiple widgets in the footer area but only have them display if the page language is EN, TH, US etc.

In the Wordpress Dashboard I went to Appearance > Widgets and created two widgets in each footer section instead of one Widget. You can then select a language at the bottom of the widget you wish the widget to display for if Polylang is enabled. For example: Write English text in one widget and and set the language to English, create another widget with Thai text (or whatever language) and set the language at the bottom to Thai. Its that simple! Of course you do have to create the languages in Polylang first.

and as @eyal_katz mentioned, if you need to add language-specific in the rest of the footer, use the PolyLang commands in the footer.php or equivalent.

标签:

提交需求或反馈

Demand feedback