Jump to content
xisto Community
Sign in to follow this  
k_nitin_r

Wordpress The_Date()

Recommended Posts

If you are a newbie at WordPress theme development, you would no doubt have looked at using the_date() in displaying the dates for each of the posts on a blog. The function has the same naming convention as the_title(), the_author(), and the_content(), so it seems like the most logical choice of WordPress API functions to display the date of a post. However, what many new theme developers do not know is that the the_date() function will only display unique dates. What I mean is that when a date is displayed on a post, if the following post has the same date, the the_date() function does not display the date. This may seem weird but that is the way it works. Perhaps somebody who does not want to display the dates over and over again would find this function useful but for the rest of us, we want the dates to be displayed for each and every post, such as in the post metadata that appears below the title of each post or below the article itself. The solution here is to use the get_the_date() function and echo the return value instead of calling the the_date() function.The get_the_date() function can also be substituted with the the_time() function with a date format parameter. The the_time() function can also be used to output the time in addition to the date, so if you are looking for the time of the post too, the the_time() post is what you are looking for.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.