Outil de recherche WordPress pour les développeurs et auteurs de thèmes



get_the_date ›

Depuis3.0.0
Dépréciéen/a
get_the_date ( $d = '', $post = null )
Paramètres: (2)
  • (string) $d Optional. PHP date format defaults to the date_format option if not specified.
    Requis: Non
    Défaut: (vide)
  • (int|WP_Post) $post Optional. Post ID or WP_Post object. Default current post.
    Requis: Non
    Défaut: null
Retourne:
  • (false|string) Date the current post was written. False on failure.
Défini(e) dans:
Codex:

Retrieve the date on which the post was written.

Unlike the_date() this function will always return the date. Modify output with the {@see 'get_the_date'} filter.



Source

function get_the_date( $d = '', $post = null ) {
	$post = get_post( $post );

	if ( ! $post ) {
		return false;
	}

	if ( '' == $d ) {
		$the_date = get_post_time( get_option( 'date_format' ), false, $post, true );
	} else {
		$the_date = get_post_time( $d, false, $post, true );
	}

	/**
	 * Filters the date a post was published.
	 *
	 * @since 3.0.0
	 *
	 * @param string      $the_date The formatted date.
	 * @param string      $d        PHP date format. Defaults to 'date_format' option
	 *                              if not specified.
	 * @param int|WP_Post $post     The post object or ID.
	 */
	return apply_filters( 'get_the_date', $the_date, $d, $post );
}