0

此代码将网站上英语(en)和泰语(th)产品的描述标题更改为“属性”。但显然它只需要为英文版返回这个,而为泰国产品返回'คุณลักษณะ'。

add_filter('woocommerce_product_description_heading','switch_product_description_heading');
     function switch_product_description_heading() {
     return 'Attributes';
}

我试过这个来获取 PolyLang 的当前语言,但没有效果:

function language_switch() {
    if(pll_current_language=='en') {
        add_filter( 'woocommerce_product_description_heading', 'switch_product_description_heading' );
        function switch_product_description_heading() {
            return 'Attributes';
        }
    } elseif (pll_current_language=='th') {
        add_filter( 'woocommerce_product_description_heading', 'switch_product_description_heading' );
        function switch_product_description_heading() {
            return 'คุณลักษณะ';
        }
    }
}

任何帮助,将不胜感激!

4

1 回答 1

0

pll_current_language是一个函数,所以你应该调用它

if(pll_current_language() =='en') {
于 2017-12-08T05:14:16.137 回答