Displays or returns the date of a post, or a set of posts if published on the same day.

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()). To repeat the date for posts published under the same day, you should use the Template Tag the_time() or get_the_date() (since 3.0) with a date-specific format string.
Use <?php the_time( get_option( 'date_format' ) ); ?> to add the date set in the admin interface.

This tag must be used within The Loop.

the_date() 描述


 <?php the_date$format$before$after$echo ); ?> 

the_date() 用法



(string) (可选) The format for the date. Defaults to the date format configured in your WordPress options. See Formatting Date and Time.

默认值: F j, Y)


(string) (可选) Text to place before the date.

默认值: None


(string) (可选) Text to place after the date

默认值: None


(boolean) (可选) Display the date (TRUE), or return the date to be used in PHP (FALSE).

默认值: TRUE

the_date() 参数


Default Usage

Displays the date using defaults.

Date as Year, Month, Date in Heading

Displays the date using the '2007-07-23' format (ex: 2004-11-30), inside an <h2> tag.

Date in Heading Using $my_date Variable

Returns the date in the default format inside an <h2> tag and assigns it to the $my_date variable. The variable's value is then displayed with the PHP echo command.

the_date() 示例


the_date() 注意


添加于 版本: 0.71

the_date() 历史


the_date() 函数的代码位于 wp-includes/general-template.php.

the_date() 源文件