[wp-hackers] Displaying date on archive pages

Harish Narayanan harish.mlists at gmail.com
Fri Dec 26 08:11:46 GMT 2008


RePost wrote:

> Does WordPress provide a tag that will let me display the date on top of
> my archives pages?
> 
> I'd like to display "Archive: December 26, 2008" or "Archive: December
> 2008," where the tag would provide the date.

There might be a simpler (as in more modern) way, but I use a
combination of is_{something}() followed by a suitable call to
the_time() to set my title.

For e.g.,


<?php /* If this is a daily archive */ } if (is_day()) { ?>
<h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2>

<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
<h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2>

<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
<h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2>

Harish


More information about the wp-hackers mailing list