根据 PolyLang 当前语言切换 WooCommerce 产品描述标题
Switching WooCommerce product description title depending on PolyLang current language
此代码将网站上英语 (en) 和泰语 (th) 产品的描述标题更改为 'Attributes'。但显然它需要 return 这只适用于英文版本,而 return 'คุณลักษณะ' 用于泰国产品。
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 'คุณลักษณะ';
}
}
}
如有任何帮助,我们将不胜感激!
pll_current_language
是 function 所以你应该称它为
if(pll_current_language() =='en') {
此代码将网站上英语 (en) 和泰语 (th) 产品的描述标题更改为 'Attributes'。但显然它需要 return 这只适用于英文版本,而 return 'คุณลักษณะ' 用于泰国产品。
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 'คุณลักษณะ';
}
}
}
如有任何帮助,我们将不胜感激!
pll_current_language
是 function 所以你应该称它为
if(pll_current_language() =='en') {