Show The Date on Every Post in WordPress

When it comes to displaying the date on blog posts, many WordPress themes – not all, but many – opt to display the date on the most recent post of the day, and then simply display the title and the content for the rest of the posts throughout the day.

This results in the content feed looking something like this:

But not everyone likes that. Luckily, there is an easy fix for this.

Show The Date on Every Post

When it comes to displaying the date, WordPress offers two functions for doing so:

If you end up using the_date, then you’re going to end up seeing the results mentioned above. Simply put, using the_date results in WordPress displaying the date once per day regardless of the number of posts for that day.

On the other hand, using the_time will unconditionally displaying when the post was published. In order to show the date on every post in WordPress, look for the call that looks something like this:

<?php the_date( get_option( 'date_format' ) ); ?>

Then replace it with this:

<?php the_time( get_option( 'date_format' ) ); ?>

And that should take care of it.

Why Does It Work This Way?

First, recall that WordPress offers two different fields for the date and the time on the General page in the Settings section of options.

Note that each of these fields uses PHP conventions for formatting the date and the time. This means that if you were to pass the the_time something like ‘F j, Y’ it would actually just display the date.

On the other hand, if you were to pass the_time something like ‘g:i a’ then it would render a timestamp. In this case, it’s 12-hour time displaying ‘am’ or ‘pm.’

So, using the_date will only result in displaying the date once for the most recent post on a given day and listing the rest of the posts below it, but if you use the_time and pass it parameters used to format the date – namely something like ‘F j, Y’ – then you’ll end up display the date for each post.

Not bad, right?

An easy alternative for unconditionally showing the date on each post.

11 Replies to “Show The Date on Every Post in WordPress”

  1. Arrgh … my bad with poor formatting, the HTML ‘code’ tag does not like having PHP tags inside it. Re-replying to (hopefully) make this more clear.


    &lt;?php echo get_the_date( get_option( 'date_format' ) ); ?&gt;

    will also show the date on every post on the same day as well.

    PS: I had to test this as it is what I have been using with my in-progress framework theme.


    &lt;?php the_date( get_option( 'date_format' ) ); ?&gt;

    would be more correct as it echoes the date by default.

    1. Your first example is right, but I’m not so sure about your second example (though I did remove the echo statements) – that’s the problem I was trying to outline in the post.

      From the Codex:

      When there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the first post (that is, the first instance of the_date())

      Unless something has changed, using the_date will not display the date for every post. We’d have to use the_time.

        1. I don’t know because I don’t know the structure of your theme or if any plugins are also hooked into places that would render that information.

          Usually it’s in the index.php template or the single.php template, but there are other places it could be depending on how your developer built the theme.

Leave a Reply