Tuesday, February 23, 2010

How to show each post’s date in WordPress

The templating system in WordPress is very flexible, and there's  rarely something you can't do or that doesn't work as you'd expect. A  notable exception however is the_date.  Its purpose is simple enough. It displays the current post's date of  creation. But on pages with more than one post (such as on many blog  home pages), something weird happens. If a number of posts on any given  page were created on the same date, the_date will only show  that date for the first of those posts.
In the early days of blogging, posts were usually listed by date,  much like a regular, paper diary. In the old default theme that comes  with WordPress a big date title is used to separate posts into days.  That's what the_date was created to do, and so it makes  sense it only displays the same date once. In most modern themes  however, people like the date to be among the meta data for each  article, so the_date falls short.