dongxuan1314 2017-12-05 04:22
浏览 622
已采纳

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

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.

  • 写回答

1条回答 默认 最新

  • dongzhuo1498 2018-12-18 07:03
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘