функция
since 3.0.0
get_the_date()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
get_the_date( string $format = '', int|WP_Post|null $post = null ): string|int|false
Описание
В отличие от the_date(), эта функция всегда возвращает дату.
Изменить вывод можно фильтром 'get_the_date'.
Оригинал (английский)
Unlike the_date() this function will always return the date.
Modify output with the ‘get_the_date’ filter.
Параметры
$format
string
необязательный
= ''
Формат даты PHP. По умолчанию используется опция 'date_format'.
$post
int|WP_Post|null
необязательный
= null
ID записи или объект WP_Post. По умолчанию — текущая запись.
Возвращаемое значение
string|int|false
Исходный код
wp-includes/general-template.php:2727
function get_the_date( $format = '', $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return false;
}
$_format = ! empty( $format ) ? $format : get_option( 'date_format' );
$the_date = get_post_time( $_format, false, $post, true );
/**
* Filters the date of the post.
*
* @since 3.0.0
*
* @param string|int $the_date Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
* @param string $format PHP date format.
* @param WP_Post $post The post object.
*/
return apply_filters( 'get_the_date', $the_date, $format, $post );
}
История изменений
| Версия | Описание |
|---|---|
| 3.0.0 | Introduced. |

