the_date()
the_date( string $format = ”, string $before = ”, strin…
the_date( string $format = ”, string $before = ”, string $after = ”, bool $echo = true )
显示或检索当前文章的撰写日期(每个日期一次)
Display or Retrieve the date the current post was written (once per date)
显示或检索当前文章的撰写日期(每个日期一次)
Display or Retrieve the date the current post was written (once per date)
目录锚点:#说明#参数#源码#笔记
说明(Description)
仅当当前帖子的日期与前一个输出的日期不同时才会输出日期。i、 e.只有一个日期列表将显示循环中每天显示的帖子价值,即使每个帖子调用函数多次。HTML输出可以用“the_date”过滤。日期字符串输出可以用“getthedate”过滤。
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $format | (string) | 如果未指定,PHP日期格式默认为date_format选项。 |
| $before | (string) | 日期之前的输出。 |
| $after | (string) | 日期之后的输出。 |
| $echo | (bool) | 默认值为“显示”。是回显日期还是返回日期。 |
源码(Source)
/**
* Display or Retrieve the date the current post was written (once per date)
*
* Will only output the date if the current post's date is different from the
* previous one output.
*
* i.e. 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.
*
* HTML output can be filtered with 'the_date'.
* Date string output can be filtered with 'get_the_date'.
*
* @since 0.71
*
* @global string|int|bool $currentday
* @global string|int|bool $previousday
*
* @param string $d Optional. PHP date format defaults to the date_format option if not specified.
* @param string $before Optional. Output before the date.
* @param string $after Optional. Output after the date.
* @param bool $echo Optional, default is display. Whether to echo the date or return it.
* @return string|void String if retrieving.
*/
function the_date( $d = '', $before = '', $after = '', $echo = true ) {
global $currentday, $previousday;
if ( $currentday != $previousday ) {
$the_date = $before . get_the_date( $d ) . $after;
$previousday = $currentday;
/**
* Filter the date a post was published for display.
*
* @since 0.71
*
* @param string $the_date The formatted date string.
* @param string $d PHP date format. Defaults to 'date_format' option
* if not specified.
* @param string $before HTML output before the date.
* @param string $after HTML output after the date.
*/
$the_date = apply_filters( 'the_date', $the_date, $d, $before, $after );
if ( $echo )
echo $the_date;
else
return $the_date;
}
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 0.71 | wp-includes/general-template.php | 12 | 7 |
笔记(Notes)
标题中的日期为年、月、日
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!