Displaying atlernate header.php content on different pages
-
Short of adding a large “If…ELSE” block to my header.php file, is there a more elegant way of displaying an alternate “header image” on different pages?
Say I have 3 “Pages”. On Page one I want to use “Header-1.jpg”. Page two would you “Header-2.jpg” and so on. Page 3 has 2 sub pages that all should share “Header-3.jpg”.
I have an all XHTML/CSS layout so in a static site thise would be super easy. I could add ‘class=header1’ to my “#Header” div. Since I am using WP I am trying to figure out how do this.
I don’t want to setup completely different templates or stylesheets. I want to keep maintenance simple. I’d prefer not to have a huge IF…ELSE block of php if possible (especially since a few pages have sub-pages).
The follow code does what I want to do but I’d rather find another way of doing this
if ($_SERVER['REQUEST_URI'] == "/cms" || $_SERVER['REQUEST_URI'] == "/cms/") {
header("Location: https://" . $_SERVER['HTTP_HOST'] . "/cms/home/"); /* Redirect browser */
exit;
}Using custom fields would be awesome but it looks like it won’t work as needed. I want to dynamically change a
$headerBG
in my header.php file depending on what page/section the user is in.Big thanks for any pointers in the right direction!
- The topic ‘Displaying atlernate header.php content on different pages’ is closed to new replies.