File this one under things you wouldn’t expect: when displaying a list of posts in WordPress, if you try to display the date using the the_date() function and have multiple posts published on the same day, only the first post will display the date.
This makes sense when you think back to the origins of blogs as date-based journal entries. But in today’s use of blogging software to run websites where the content isn’t always categorized by date, this convention is less useful.
One way is to tap into your blog options and retrieve the date format you’ve set in the General Settings for your site:
<?php the_time(get_option('date_format'));Â ?>
Or you can customize the format with a date-specific format string, for example using the_time():
<?php the_time('l, F j, Y'); ?>
Which would generate something like: Monday, January 1, 2010
Personally, I’d recommend this latter option as it gives you more granular control in case you ever need to format the date differently in different locations of your site.Tags: WordPress