0

I wonder if there is a specific way to create a custom 404 header template.

This can be done for secondary page, but creating a header-404.php doesn't do the trick.

Am I really supposed to create an if in the main header checking whether the is_404() returns true?

Thanks Andrea

  • That specific example is covered on the Codex page for get_header(). TL;DR: if( is_404() ) { get_header( '404' ); } ... in which case, it will use header-404.php. – Pat J Apr 16 '14 at 21:05
0

Further to my comment:

I ran across a very similar issue with get_sidebar(), which I expected (incorrectly) to work the same as get_template_part(). A work-around is to do something like this:

// instead of using get_header( '404' ); , do this:
get_template_part( 'header', '404' );
// which should select 'header-404.php', or, if it doesn't
// exist, fail over to 'header.php'

References

0

As said in Codex

header-404.php is not auto loaded on 404.php template, you have to create it but also call the header using

get_header( '404' );

instead of get_header().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.