看起来您的主题缺少wp_footer()
函数,但包含wp_header()
作用
我可以在默认主题上复制此行为,方法是删除wp_footer()
.
管理栏的HTML来自核心代码中的这一部分:
add_action( \'wp_footer\', \'wp_admin_bar_render\', 1000 );
查看默认主题通常很有用:
中的最后三行footer.php
主题中的文件有:
<?php wp_footer(); ?>
</body>
</html>
请记住
writing a good theme is not an easy task. 您只需阅读wordpress上的主题审查流程。org查看所涉及的艰苦工作。
以下内容通过wp_head()
功能,用于登录用户:
管理栏样式表即将推出
<link rel=\'stylesheet\'
id=\'admin-bar-css\'
href=\'http://example.com/wp-includes/css/admin-bar.min.css?ver=3.8.3\'
type=\'text/css\'
media=\'all\' />
额外的空白来自
<head>
标签:
<style type="text/css" media="screen">
html { margin-top: 32px !important; }
* html body { margin-top: 32px !important; }
@media screen and ( max-width: 782px ) {
html { margin-top: 46px !important; }
* html body { margin-top: 46px !important; }
}
</style>
当用户在其配置文件页面上选择工具栏选项时:

打印时禁用管理栏的部分:
<style type="text/css" media="print">#wpadminbar { display:none; }</style>
总而言之:
如果您已登录,并且选择了工具栏选项,则主题页将有额外的空间(32px
) 在顶部。此空间中填充了来自wp_footer()
, 因此,请确保在主题的页脚中包含此函数。
希望这有帮助。