[wp-hackers] Displaying date on archive pages

Kim Parsell kparsell-wp at kpdesign.net
Fri Dec 26 18:01:20 GMT 2008


Try this instead:

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

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

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


Kim

-------------------------------

RePost wrote:
> Harish Narayanan wrote:
>> 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>
>>   
> Thanks, Harish.
>
> This returns an "unexpected '}' error" for the first line.
>
> Wish I could do more with php than write includes. Do you see an error 
> here?
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list