英文:
Hide language switcher names
问题
我试图隐藏语言切换器中的语言名称,只显示国旗。WPML支持告诉我,标准语言切换器由主题(Flatsome)提供,所以他们无法帮助。
Flatsome支持告诉我,他们无法帮助自定义解决方案。
我尝试通过“检查页面”自己找出负责这些语言名称的部分,但我发现影响了整个页眉-主要内容。没有找到仅负责“语言名称”的部分。
所以我再次向WPML支持询问,我可以使用什么CSS或其他内容来隐藏这些名称,答案是:“function engage_header_langs()”。我不明白接下来该怎么做。
有人可以帮助吗?
英文:
I am trying to hide language names in the language switcher and show only flags. WPML support told me, that the standard language switcher is provided by the theme (Flatsome), so they couldn't help.
Flatsome support told me, that can't help with custom solutions.
I was trying to find by myself through the „inspect page“ what is responsible for those language names, but all i found were affected on the whole header-main content. Not found, what is responsible only for „language names“.
So i asked WPML support again, what i can use for CSS or something to hide those names and the answer was: "function engage_header_langs()". And i do not understand what to do next.
Can anyone help with this?
答案1
得分: 0
以下是您要翻译的内容:
"The function you were given can likely be hooked into if you review your plugin's documentation. However, this can be done with some simple jQuery as shown in the snippet below. If you are using a custom JS file you can add this there (assuming you are already out of noConflict mode). If not, you can use the last snippet noted for your functions.php file. Update: I updated the script to adjust the css to display after it has removed the text. You will now need to add that to the functions.php file and the line of css above that to style.css (or wherever you are putting your css)
$(".has-dropdown.header-language-dropdown a").contents().filter(function() {
return this.nodeType === 3;
}).remove();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul>
<li class="has-dropdown header-language-dropdown">
<a href="#">
"Eesti"
<i class="image-icon">
<img src="https://cdn.pixabay.com/photo/2015/11/12/16/24/flag-1040595_960_720.png">
</i>
</a>
</li>
</ul>
Add this to style.css
.has-dropdown.header-language-dropdown a {
display:none;
}
//If adding to WordPress functions.php, use this block.
function add_script_to_head() {
?>
<script>
jQuery(document).ready(function($) {
$(".has-dropdown.header-language-dropdown a").contents().filter(function() {
return this.nodeType === 3;
}).remove().css('display', 'revert');
});
</script>
<?php
}
add_action('wp_head', 'add_script_to_head');
"
英文:
The function you were given can likely be hooked into if you review your plugin's documentation.
However, this can be done with some simple jQuery as shown in the snippet below. If you are using a custom JS file you can add this there (assuming you are already out of noConflict mode). If not, you can use the last snippet noted for your functions.php file.
Update: I updated the script to adjust the css to display after it has removed the text. You will now need to add that to the functions.php file and the line of css above that to style.css (or wherever you are putting your css)
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
$(".has-dropdown.header-language-dropdown a").contents().filter(function() {
return this.nodeType === 3;
}).remove();
<!-- language: lang-html -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul>
<li class="has-dropdown header-language-dropdown">
<a href="#">
"Eesti"
<i class="image-icon">
<img src="https://cdn.pixabay.com/photo/2015/11/12/16/24/flag-1040595_960_720.png">
</i>
</a>
</li>
</ul>
<!-- end snippet -->
//Add this to style.css
.has-dropdown.header-language-dropdown a {
display:none;
}
//If adding to WordPress functions.php, use this block.
function add_script_to_head() {
?>
<script>
jQuery(document).ready(function($) {
$(".has-dropdown.header-language-dropdown a").contents().filter(function() {
return this.nodeType === 3;
}).remove().css('display', 'revert');
});
</script>
<?php
}
add_action('wp_head', 'add_script_to_head');
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论