WordPress at a glance

get_lastpostdate() WP 1.0

Retrieve the date that the last post was published.

The server timezone is the default and is the difference between GMT and server time. The 'blog' value is the date when the last post was posted. The 'gmt' is when the last post was posted in GMT formatted date.

Is the basis for: get_lastpostmodified()
Works based on: _get_last_post_time()
✈ 1 time = 0.001661s = very slow | 50000 times = 0.20s = very fast | PHP 7.0.5, WP 4.4.2
Hooks from the function
Return

String. The date of the last post.

Usage

get_lastpostdate( $timezone, $post_type );
$timezone(string)
The timezone for the timestamp. Accepts 'server', 'blog', or 'gmt'. 'server' uses the server's internal timezone. 'blog' uses the post_modified field, which proxies to the timezone set for the site. 'gmt' uses the post_modified_gmt field.
Default: 'server'
$post_type(string)
The post type to check.
Default: 'any'

Changelog

Since 0.71 Introduced.
Since 4.4.0 The $post_type argument was added.

Code of get lastpostdate: wp-includes/post.php WP 5.2.4

<?php
function get_lastpostdate( $timezone = 'server', $post_type = 'any' ) {
	/**
	 * Filters the date the last post was published.
	 *
	 * @since 2.3.0
	 *
	 * @param string $date     Date the last post was published.
	 * @param string $timezone Location to use for getting the post published date.
	 *                         See get_lastpostdate() for accepted `$timezone` values.
	 */
	return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date', $post_type ), $timezone );
}

Related Functions

From tag: date time

More from category: Other

No comments
    Hello, !     Log In . Register