Skip to content


WordPress Tip #2 – Double Dates

On a fairly regular basis, I need to create a custom query to display a list of posts on a page, for example, to display a list of the most popular posts.

On several occasions, after doing this, I’ve noticed that in the list of posts, some of the dates were missing.

On closer inspection, I discovered that the missing dates belonged to posts which were published on the same day as another post.

It turns out that if you use the_date() to display your post date within the loop, it will only display the date on the first post to be published on that day. If more posts were published on the same day, their date will be omitted.

Fortunately, it’s easy to get around this, by using the_time() instead of the_date(), as follows:

Selec All Code:
the_time(get_option('date_format'));

The get_option(‘date_format’) function ensures that the date will be displayed in the format that you chose in the WordPress general settings panel.

Now you can publish as many posts per day as you wish!

Posted in Editorial Pick, General, Web, Web Design.

Tagged with , , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.