切换到其他语言时更改徽标图像

时间:2014-08-14 12:48:12

标签: wordpress plugins

我有这个多语种网站。有没有办法在切换到"中文后可以将logo.png更改为不同的.png?"

我现在正在使用polylang插件,这就是我一起拼凑的:

$(function() {


if (pll_current_language == 'en') {
    $('.logo').css("background-image", "url(images/logo.png)");  
} else if (pll_current_language == 'zh') {
    $('.logo').css("background-image", "url(images/logo-CN.png)");  
} else {
    $('.logo').css("background-image", "url(images/logo.png)");  
}
});

1 个答案:

答案 0 :(得分:0)

更改

if (pll_current_language == 'en') {
    $('.logo').css("background-image", "url(images/logo.png)");  
} else if (pll_current_language == 'zh') {
    $('.logo').css("background-image", "url(images/logo-CN.png)");  
} else {
    $('.logo').css("background-image", "url(images/logo.png)");  
}

if (pll_current_language() == 'en') {
    $('.logo').css("background-image", "url(images/logo.png)");  
} else if (pll_current_language() == 'zh') {
    $('.logo').css("background-image", "url(images/logo-CN.png)");  
} else {
    $('.logo').css("background-image", "url(images/logo.png)");  
}

应该有用,你错过了"()"在" pll_current_language"

之后

编辑:试试这个:

$( document ).ready(function() {
<?php
if (pll_current_language() == 'en') {
?>
    $('.logo').css("background-image", "url(images/logo.png)");  
<?php
} else if (pll_current_language() == 'zh') {
?>
    $('.logo').css("background-image", "url(images/logo-CN.png)");  
<?php
} else {
?>
    $('.logo').css("background-image", "url(images/logo.png)");  
<?php
}
?>
});