WordPress在头部文件header中调用wp_head函数后,顶部会出现28px的空白,如何去掉?新手站长网分享:
去掉wp_head函数头部空白的方法
wp_head是WordPress很重要的一个函数,在头部调用这个函数后就会出现28px的顶部空白,如何去掉顶部空白?新手站长网分享解决方法:
在主题目录下的functions.php文件中插入以下代码即可:
<?php
function my_function_admin_bar(){ return false; } add_filter( 'show_admin_bar' , 'my_function_admin_bar');
?>
将上述代码粘贴到你的functions.php文件中,即可解决。
什么原理?我们把my_functions_admin_bar的值设置为false,这样加载show_admin_bar为false,所以
<style type="text/css">
html { margin-top: 28px !important; }
* html body { margin-top: 28px !important; }
</style>
就是上面的css导致我们的顶部出现28像素的空白。
阿里云官方活动:https://t.aliyun.com/U/FzmsXA
腾讯云官方活动:https://curl.qcloud.com/oRMoSucP
