admin管理员组文章数量:1335624
Using Hook, is there a way to remove the Header and Footer from the specific page that is trying to access by users, if the current user is not logged on?
function footer_header_remove() {
if(!is_user_logged_in() && is_page('the-page')){
//Remove Header and Footer of "the-page"
}
}
add_action('???????????', 'footer_header_remove');
Using Hook, is there a way to remove the Header and Footer from the specific page that is trying to access by users, if the current user is not logged on?
function footer_header_remove() {
if(!is_user_logged_in() && is_page('the-page')){
//Remove Header and Footer of "the-page"
}
}
add_action('???????????', 'footer_header_remove');
Share
Improve this question
asked Jun 30, 2020 at 7:33
PolarPolar
1311 silver badge13 bronze badges
1
- Do you have a page template for that page or? – Milosh N. Commented Jun 30, 2020 at 9:09
1 Answer
Reset to default 2You have a lot of ways to do this.
The first important thing is next: You must have a header or a footer (default header and footer, from WP) if you want to have functionality.
E.g If you are loaded scripts or styles in function.php
they will be broken, because you can't load them without header or footer.
You can create more types of footers or headers where if you have one page or one type of page templates you can do that on this way:
// your example-template.php
<?php /* Template Name: Example Template */
if(!is_user_logged_in()) {
get_header('blank-header');
}
And for the footer do the same thing.
In your case, where you want to load or not header and footer from the function, you can use 'init'
hook or you can use the last hook before loading the template is 'template_redirect'
that is your choice.
本文标签: hooksRemove Header and Footer if user is not logged on
版权声明:本文标题:hooks - Remove Header and Footer if user is not logged on 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742307024a2450120.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论