WordPress Code Reference

WordPress Code Reference

WordPress Code Reference is a developer site with a plethora of code functions for WordPress sites. There are lists with links to information on widgets, shortcode, and more on the right side under API. The list on the left offers all the updated code options for HTML, PHP, and JavaScript functions. There is an abundance of learning materials to be able to code new functions on your site. There is also a search bar for looking up specific functions and codes.

the_date() Function

The date function allows you to retrieve and display the date of posts. This function will only display one listing of the date even if the function is called several times for each post. Uses include get_the_date() which retrieves the date the post was written and is_new_day() which determines if the publish date of the current post is on the same date as the previous post in the loop.

Format Parameters

The format parameters for the_date() function are $format which defaults to the 'date_format' option, $before and $after which outputs before or after the date, and $echo which is weather or not to echo the date. The default value for $format, $before, and $after are '' and the default for $echo is true. Some value options for $format are 'Y-m-d" or 'M,d,y'. For $before and $after you could input '<h2>' to target dates inside of h2 elements.

Summary

the_date() function allows developers to display post dates in their chosen format.