Reputation: 4936
i wondering how can i remove header and footer from the one particular post. i have searched around google and wordpress but i didn't get anything which can prevent header and footer to display.
i am using memberpress plugin and i am changing the design of registration form. here i am not able to use custom template also.
i know for page we can prevent to display some of the code for that page by using following code but need help on post.
if(!is_page('1'))
//not to display
any help?
Upvotes: 1
Views: 1881
Reputation: 2942
There are two ways..
(1)create php file as 'single-PID.php' in your selected theme folder suppose that you added post and the post id is 18(remember post id is important) and on that you don't want header and footer. so
get_header()
and get_footer()
.now add below function in 'function.php' file :
function my_single_template_by_post_id( $located_template ) {
return locate_template( array( sprintf( "single-%d.php", absint( get_the_ID() ) ), $located_template ) );
}
add_filter( 'single_template', 'my_single_template_by_post_id' );
admin side ,select posts from menu ...click view on post that has id '18'
(2)create php file as 'page-PID.php' in your selected theme folder suppose that you added page and the page(save as post type 'page' in wp-post database table) id is 8(remember post id is important) and on that you don't want header and footer. so
get_header()
and get_footer()
.Upvotes: 1
Reputation: 6174
You can use is_single function just like is_page.
http://codex.wordpress.org/Function_Reference/is_single
Copied from Codex:
is_single(); // When any single Post page is being displayed.
is_single('17'); // When Post 17 (ID) is being displayed.
is_single(17); // When Post 17 (ID) is being displayed. Integer parameter also works
Upvotes: 3