Header for Date Archives

If you go to the day, month, or year archive of your blog it will most likely look exactly like your main blog. There’s nothing that describes the actual time period of the posts you’re viewing. This adds a header to these pages for more context.

<?php
/**
* Header for Date Archives
*
* @author Bill Erickson
* @link http://www.billerickson.net/code/header-date-archives/
*/
function be_date_archive_header() {
if( ! is_date() )
return;
if( is_year() )
$title = get_query_var( 'year' );
if( is_month() )
$title = single_month_title( ' ', false );
if( is_day() ) {
$date = get_query_var( 'day' ) . single_month_title( ' ', false );
$title = date( 'F j, Y', strtotime( $date ) );
}
if( $title )
echo '<h1 class="archive-title">' . $title . '</h1>';
}
add_action( 'genesis_before_loop', 'be_date_archive_header' );
view raw functions.php hosted with ❤ by GitHub

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk