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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742307025a4419143.html
评论列表(0条)