It may be the syntax, try:
<?php
if !(is_page(24)) {
get_header();
} else {
get_header('myheader');
}
?>
Edited above to remove ‘ wrapping page id, not needed for page id.
Above says if not page 24 get header.php, when that fails ( it is page 24), then get header-myheader.php
Or do you plan on having more custom headers?
If you do, then you can add an array for is_page.
You have already created the file header-myheader.php based on header.php and made the appropriate edits? Yes?
the posts page does not work with ‘is_page()’;
the check for the posts page is ‘is_home()’;
for the front page use ‘is_front_page()’
http://codex.wordpress.org/Conditional_Tags
@alchymyth
What if the posts page noted is a page of posts? I supposed it was. Would above not work then? And I guess you would be correct if the home page is front-page.php and not a custom home.php?
Can you clarify? (please)
I think the Codex is quite clear with the conditional tags;
a ‘page of posts’ is a static page (which is just using a page template) which can get checked by using ‘is_page()’;
regardless if the theme has a front-page.php to render the home page (http://codex.wordpress.org/Template_Hierarchy#The_Template_Hierarchy_In_Detail ), using ‘is_front_page()’ should work as a conditional tag if you want to check for the front page, and it does not matter if it is a static front page or the posts page.
http://codex.wordpress.org/Conditional_Tags#The_Front_Page
to distinguish the posts page, use ‘is_home()’.
http://codex.wordpress.org/Conditional_Tags#The_Main_Page
Thank you both for your responses.
@alchymyth – I went with your solution and read up on the conditional tags. Rewrote the code to:
if ( is_home() ) :
get_header('myheader' );
elseif ( is_front_page() ) :
get_header( );
endif;
Works perfectly! Thanks again!