There is a question in the StudioPress forum which asks how to add a date title to the date archives – the page that displays all posts from a particular month, such as https://www.calliaweb.co.uk/2014/02/
Thinking this would be a nice feature for this site I set about writing a function to achieve this.
On this site I’ve moved the location of my titles so they are above the content and sidebar, so the code below is not exactly what I am using here, but should work for most themes with the titles appearing in the usual place.
This code goes in your functions.php file.
As always I remind you to have a backup of your website before you edit your functions file and if you are not comfortable with editing your functions file then do ask a Genesis developer to do it for you. You\’ll find loads of Genesis developers hanging out on Twitter under the #genesiswp hashtag.
You can also see this code on github.
add_action( 'genesis_before_loop','jmw_add_archive_date_title', 15 );
/**
* Add date headline to date archive pages.
*
* If we're not on a date archive page then nothing extra is displayed.
*
* The date is marked up as a level 1 heading.
*
* @return null Return early if not date archive
*/
function jmw_add_archive_date_title() {
if( !is_date() ) {
return;
}
echo '<div class="archive-description">';
echo '<h1 class="archive-title">'. single_month_title( ' ', FALSE ) .' Archive</h1>';
echo '</div>';
}
Leave a Reply