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時區的當前日期。

顯示寫文章的工作日。

只有在當前文章的工作日與前一個工作日不同的情況下,才會輸出該工作日。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 );
}
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 ); }
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
檢視更多 >