get_lastpostdate()
Получает дату и время, когда был опубликована последняя запись на сайте.
В параметр $timezone указывается часовой пояс. По умолчанию: server
он равен времени GMT + время сервера. Значение blog
- дата, когда был опубликован последний пост. gmt
, когда последний пост был опубликован в GMT формате.
Работает на основе: _get_last_post_time()
Основа для: get_lastpostmodified()
1 раз — 0.001661 сек (очень медленно) | 50000 раз — 0.20 сек (очень быстро) | PHP 7.0.5, WP 4.4.2
Хуки из функции
Возвращает
Строку
. The date of the last post.
Использование
get_lastpostdate( $timezone, $post_type );
- $timezone(строка)
Временная зона для штампа времени (timestamp). Может быть:
server
- внутренне время сервера.blog
- использует время из поляpost_modified
временную зону установленную для сайта.gmt
- использует время из поляpost_modified_gmt
.
По умолчанию: 'server'
- $post_type(строка)
- Название типа записи последнюю дату публикации которой нужно получить.
По умолчанию: 'any'
Примеры
#1 Демонстрация работы
echo get_lastpostdate( $timezone = 'server', $post_type = 'any' ); // выведет: 2016-04-05 17:56:29.000000 echo get_lastpostdate( $timezone = 'blog', $post_type = 'post' ); // выведет: 2016-03-05 01:46:44 echo get_lastpostdate( $timezone = 'gmt', $post_type = 'post' ); // выведет: 2016-03-04 20:46:44
Список изменений
С версии 0.71 | Введена. |
С версии 4.4.0 | The $post_type argument was added. |
Код get_lastpostdate() get lastpostdate WP 6.1.1
function get_lastpostdate( $timezone = 'server', $post_type = 'any' ) { $lastpostdate = _get_last_post_time( $timezone, 'date', $post_type ); /** * Filters the most recent time that a post on the site was published. * * @since 2.3.0 * @since 5.5.0 Added the `$post_type` parameter. * * @param string|false $lastpostdate The most recent time that a post was published, * in 'Y-m-d H:i:s' format. False on failure. * @param string $timezone Location to use for getting the post published date. * See get_lastpostdate() for accepted `$timezone` values. * @param string $post_type The post type to check. */ return apply_filters( 'get_lastpostdate', $lastpostdate, $timezone, $post_type ); }