SO网友:Milosh N.
你有很多方法可以做到这一点。
第一件重要的事情是下一件事:如果您想拥有功能,您必须拥有页眉或页脚(来自WP的默认页眉和页脚)。
E、 g如果在中加载了脚本或样式function.php 它们将被破坏,因为没有页眉或页脚就无法加载它们。
You can create more types of footers or headers 如果您有一个页面或一种类型的页面模板,可以通过以下方式完成:
// your example-template.php
<?php /* Template Name: Example Template */
if(!is_user_logged_in()) {
get_header(\'blank-header\');
}
对于页脚,做同样的事情。
在您的情况下,如果要从函数中加载或不加载页眉和页脚,可以使用\'init\' 钩子,也可以在加载模板之前使用最后一个钩子\'template_redirect\' 这是你的选择。