Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



the_date ›

Od0.71
Przestarzałyn/a
the_date ( $d = '', $before = '', $after = '', $echo = true )
Parametry: (4)
  • (string) $d Optional. PHP date format defaults to the date_format option if not specified.
    Wymagane: Nie
    Domyślny: (puste)
  • (string) $before Optional. Output before the date.
    Wymagane: Nie
    Domyślny: (puste)
  • (string) $after Optional. Output after the date.
    Wymagane: Nie
    Domyślny: (puste)
  • (bool) $echo Optional, default is display. Whether to echo the date or return it.
    Wymagane: Nie
    Domyślny: true
Powrót:
  • (string|void) String if retrieving.
Zdefiniowane na:
Codex:

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'.



Źródło

function the_date( $d = '', $before = '', $after = '', $echo = true ) {
	global $currentday, $previousday;

	if ( is_new_day() ) {
		$the_date    = $before . get_the_date( $d ) . $after;
		$previousday = $currentday;

		/**
		 * Filters 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;
		}
	}
}