the_date() only displays the date in its first instance

This feature of WordPress the_date() template tag is quirky to me, but I guess it works that way in most blog engines out there.

I came across this cautionary message in the WordPress Codex for the_date() function, pointed to me through the Support Forum when I had trouble getting to show dates in some posts (I was tinkering with another layout I made).

SPECIAL NOTE: 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())…

When you think about it, that’s how date displays usually work (in Blogger, for example): they don’t repeat themselves for every post and are usually separate from the posts themselves.

But what about those WordPress themes that display dates for every post? They use the_time().

…To repeat the date for posts published under the same day, you should use the Template Tag the_time() with a date-specific format string.

Imagine my frustration before and after I discovered this. I didn’t remember bumping into those reminders the hundreds of times I referred to the Codex! I even thought it was a query_posts() quirk! But I realize the error in assuming the_date and the_time work in parallel.

It is a tad irritating, however, that one is unable to take advantage of the date formatting option found in the WordPress admin panel when one uses the_time. That also implies mass editing across possibly many template files if one decides to shift to a different date/time format. And because I am flaky, I am the victim here.

As for that layout, I hope to use it soon.

1 reply

Reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> Anything in between < and > will be treated as HTML, so you might want to use character entities if you have to display literal markup.

Technology & Computers - Top Blogs Philippines