the_weekday_date

函数
the_weekday_date ( $before = '', $after = '' )
参数
  • (string) $before Optional. Output before the date. Default empty.
    Required:
    Default: (empty)
  • (string) $after Optional. Output after the date. Default empty.
    Required:
    Default: (empty)
定义位置
相关方法
the_weekdaythe_datethe_modified_dateget_feed_build_datethe_date_xml
引入
0.71
弃用
-

the_weekday_date: 这个函数检索给定日期的日期和工作日名称或WordPress时区的当前日期。

显示写文章的工作日。

只有在当前文章的工作日与前一个工作日不同的情况下,才会输出该工作日。

function the_weekday_date( $before = '', $after = '' ) {
	global $wp_locale, $currentday, $previousweekday;

	$post = get_post();

	if ( ! $post ) {
		return;
	}

	$the_weekday_date = '';

	if ( $currentday !== $previousweekday ) {
		$the_weekday_date .= $before;
		$the_weekday_date .= $wp_locale->get_weekday( get_post_time( 'w', false, $post ) );
		$the_weekday_date .= $after;
		$previousweekday   = $currentday;
	}

	/**
	 * Filters the localized date on which the post was written, for display.
	 *
	 * @since 0.71
	 *
	 * @param string $the_weekday_date The weekday on which the post was written.
	 * @param string $before           The HTML to output before the date.
	 * @param string $after            The HTML to output after the date.
	 */
	echo apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after );
}

常见问题

FAQs
查看更多 >