WordPress Code Reference

The WordPress Code Reference is official WordPress documentation that provides an automatically generated list of Functions, Hooks, Classes, and Methods available to use in creating a WordPress site. The list is generated using WP Parser, an open-source program that generates listings of each entity from the WordPress core files. This makes it a technically more accurate source of information on specific functions, methods, etc. than the WordPress Codex, a documentation wiki that WordPress community members are able to modify. Code Reference documentation is always up to date, and each entry displays the relevant parameters, the source code, related entries, and a changelog. The Code Reference also contains a search feature, allowing you to look up any entity by name or functionality.

the_date() Function

The function the_date() displays or retrieves the date of a post, if it is different from the previous output. From its page in the Code Reference, "Only one date listing will show per day worth of posts shown in the loop, even if the function is called several times for each post." If several posts are made in the same day, the function will only display the date for the first post. This function uses the the_date hook to filter HTML output, and string output can be filtered using get_the_date.

the_date() Format Parameters

The $format parameter can be used to set the PHP date format (for example, 'Y-m-d' will display the date as, "Year-Month-Day;" if it is August 12th, 2026, the date will display as, "2026-08-12"). It is an optional string parameter, and defaults to the 'date_format' option. Other parameters are $before, which sets output before the date; $after, which sets output after the date; and $display, a boolean that sets whether to echo or return the date.

Summary

The WordPress Code Reference is an auto-generated list of WordPress functions, hooks, methods, and classes that is derived from the WordPress core files and is kept up to date with the latest WordPress version. The function the_date() displays or retrieves a post's date, if it is the first post of a given day. The $format parameter allows alteration of the display format for the date retrieved.