Skip to:

Re: Hooking into get_header to replace header.php in certain files?



Thanks so much … this is making more and more sense. One question, though – what would be the best way to place such a condition into the template (while keeping as much of the parent template intact as possible and avoiding tedious file-by-file manipulation)?

Could I, for example, place this sort of condition atop the normal header.php file, moving all the normal header HTML markup into the final else condition and removing the get_header(); call? Would this make sense:

<?php if ( bp_is_user_profile() ) {
include (TEMPLATEPATH . '/profileHeader.php'); //include this header on profile pages
} elseif ( other_conditions() ) {
include (TEMPLATEPATH . '/otherHeader.php'); //include this header on profile pages
} else {
include (TEMPLATEPATH . '/homeHeader.php'); //include normal header markup placed into homeHeader.php
} : ?>

Would that code work? Does it need an endif? Not sure if the closure of it is correct either, what with the colon and all. Regardless, once the syntax is corrected, it seems like an easy thing to maintain, since it would only involve changing the header.php, then creating whatever other headers I might need. Then every time wordpress looked at header.php it would decide which header markup to include. Is that a correct assessment?

Is there some more efficient implementation of this type of conditional statement I’m not thinking of?

Thanks again for all your help, Travel-junkie!

Skip to toolbar