我正在使用WPML语言,但找不到下一件事的解决方案:
在语言切换器上,我想隐藏语言,例如 - “他”,如果当前语言是例如“ar”,那么当我们在阿拉伯语网站上时,我们不会在选择器上看到希伯来语,同样的事情如果我们使用希伯来语,则不会显示阿拉伯语。
关于缩短的话:我想要的是 - 如果我们在阿拉伯语网站上 - 希伯来语标志将被隐藏。
我尝试了什么:
function language_selector_flags(){
$languages = icl_get_languages('skip_missing=0');
if(!empty($languages)){
if(ICL_LANGUAGE_CODE=='en')
{
$order = array('ar'); //Specify your sort order here
}
elseif(ICL_LANGUAGE_CODE=='he')
{
$order = array('en', 'ar'); //Specify your sort order here
}
foreach ($order as $l) {
if (isset($languages[$l])) {
$l = $languages[$l]; //grab this language from the unsorted array that is returned by icl_get_languages()
//Display whatever way you want -- I'm just displaying flags in anchors (CSS: a {float:left; display:block;width:18px;height:12px;margin:0 2px;overflow:hidden;line-height:100px;})
if($l['active']) { $class = "active"; $url=""; } else { $class = ''; $url = 'href="'.$l['url'].'"'; }
echo '<a '.$url.' style="background:url('.$l['country_flag_url'].') no-repeat;" class="flag '.$class.'">';
echo $l['language_code'].'';
}
}
}
}
它根本不影响选择器。