How to remove Header-extras on specific pages
Posted: 2019-05-27 13:19
Hi,
I have a common header in my hooks/header-extras.php and show it on some 20+ pages but I would like to remove it on just a couple of pages (i.e. not include header-extras on those selected pages). The pages are ones I've created in my hooks folder (a calendar page and GDPR policy page).
Obviously I don't want to create the same header using hooks for each individual page under hooks folder page.php and then not adding a header on the selective pages (although this would work), I'd rather continue to use header-extras (or footer-extras) to show the common header and add code? to the selected pages to not show/remove my header (header-extras.php).
Is there a quick, simple way, code to do this?
I presently get round it in an undesirable way by duplicating my header.php as header1.php edited to remove the last line:
<?php if(!defined('APPGINI_SETUP') && is_file(dirname(__FILE__) . '/hooks/header-extras.php')){ include(dirname(__FILE__).'/hooks/header-extras.php'); } ?>
I then point my 2 hooks/page.php files to the alternative header1.php by change to line:
include_once("../header.php"); to show include_once("../header1.php");
This works but I'm sure there's a simple more correct way!
Help appreciated, cheers, Ron
I have a common header in my hooks/header-extras.php and show it on some 20+ pages but I would like to remove it on just a couple of pages (i.e. not include header-extras on those selected pages). The pages are ones I've created in my hooks folder (a calendar page and GDPR policy page).
Obviously I don't want to create the same header using hooks for each individual page under hooks folder page.php and then not adding a header on the selective pages (although this would work), I'd rather continue to use header-extras (or footer-extras) to show the common header and add code? to the selected pages to not show/remove my header (header-extras.php).
Is there a quick, simple way, code to do this?
I presently get round it in an undesirable way by duplicating my header.php as header1.php edited to remove the last line:
<?php if(!defined('APPGINI_SETUP') && is_file(dirname(__FILE__) . '/hooks/header-extras.php')){ include(dirname(__FILE__).'/hooks/header-extras.php'); } ?>
I then point my 2 hooks/page.php files to the alternative header1.php by change to line:
include_once("../header.php"); to show include_once("../header1.php");
This works but I'm sure there's a simple more correct way!
Help appreciated, cheers, Ron