I’m trying to load load only the page content (prevent loading header menu or footer) if the url contains ?mode=quick
I’ve tried adding the following to the top of my header.php to try only loading the content of the page but it didn’t work.
<?php
if ($_GET['mode'] == 'quick'){
the_content();
exit();
}
?>
I was able to prevent the footer from loading by adding the following code to page.php
before the last line.
<?php
if ($_GET['mode'] == 'quick'){
exit();
}
?>
<?php get_footer(); ?> // Last line
Is there a way to do a similar thing but prevent the header from loading as well?
index page
header.php
I hope it will be helpful for you
Keep it simple! 🙂
You simply need to invert where you put your logic:
The solution I found was to create a duplicate of
header.php
and rename it toheader-empty.php
I modified the code in the new header file to strip it down. Then I had it conditionally load that header if the url parameter was correct.
WordPress requires the
get_header()
function so I couldn’t avoid calling it.Beginning of
page.php
End