Yes it is. This is (very much) example code, but this is the basis of how it would work.
<?php
$check_date = '2015-09-03';
if( get_the_date() <= $check_date ){
get_header( 'alternate' );
}
else{
get_header();
}
?>
And you’d need two files – the standard header.php
file for your nornal header, and header-alternate.php
for the alternative header.
Thanks Catacautic.
I have another question. Would I able to have more than one alternative header? Basically what I’m trying to do is have all my posts from 2013 have one header, 2014 have another header and 2015 another.
Yes, that’s easy to do. Just add in more elseif()
statements for each date range that you want.
Forgiven my ignorance, but how would deal with the $check_date? Would I need one for each year?
Yes, you’d set a differnt br3eak point for each time period that you need.
If you are going to be using a different header for each year, you could also do something like this…
<?php get_header (get_the_date( 'Y' )); ?>
That will get the header for the correct year and default back to the standard header file if there’s no header for that year. So you’d have files like:
header-2015.php
header-2014.php
header-2013.php
header.php
Awesome catacaustic! Works perfectly.
Many thanks!