我使用下面的代码添加了一个短代码,并使用css添加了样式。两人在本网站中都工作得很好:
// PHP: Add this to your functions.php file
function polylang_flags_shortcode() {
ob_start();
pll_the_languages(array('show_flags'=>0,'show_names'=>1));
$flags = ob_get_clean();
return '' . $flags . '';
}
add_shortcode('POLYLANG', 'polylang_flags_shortcode');
/* CSS Polylang Flags/Names Inline */
.polylang-flags {
list-style-type: none;
margin: 0;
padding: 0;
}
.polylang-flags li {
display: inline;
}现在,我需要隐藏目前的语言。
请提供关于添加或修改代码的建议。
谢谢
发布于 2018-06-19 10:29:05
您需要向此函数添加hide_current参数。当您在代码中使用插件函数时,一定要检查函数是否存在。如果插件被禁用,您的网站将继续工作:)
function polylang_flags_shortcode() {
ob_start();
if(function_exists('pll_the_languages'))
{
echo '';
pll_the_languages(array(
'show_flags' => 0,
'show_names' => 1,
'hide_current' => 1,
));
echo '';
}
return ob_get_clean();
}
add_shortcode('POLYLANG', 'polylang_flags_shortcode');我还移动了ul部分!
https://wordpress.stackexchange.com/questions/306420
复制相似问题