返回介绍

get_lastpostmodified()

发布于 2017-09-10 23:28:13 字数 3281 浏览 1087 评论 0 收藏 0

get_lastpostmodified( string $timezone = 'server',  string $post_type = 'any' )

Get the timestamp of the last time any post was modified.


description

The server timezone is the default and is the difference between GMT and server time. The ‘blog’ value is just when the last post was modified. The ‘gmt’ is when the last post was modified in GMT time.


参数

$timezone

(string) (Optional) The timezone for the timestamp. See get_lastpostdate() for information on accepted values.

Default value: 'server'

$post_type

(string) (Optional) The post type to check.

Default value: 'any'


返回值

(string) The timestamp.


源代码

File: wp-includes/post.php

function get_lastpostmodified( $timezone = 'server', $post_type = 'any' ) {
	/**
	 * Pre-filter the return value of get_lastpostmodified() before the query is run.
	 *
	 * @since 4.4.0
	 *
	 * @param string $lastpostmodified Date the last post was modified.
	 *                                 Returning anything other than false will short-circuit the function.
	 * @param string $timezone         Location to use for getting the post modified date.
	 *                                 See get_lastpostdate() for accepted `$timezone` values.
	 * @param string $post_type        The post type to check.
	 */
	$lastpostmodified = apply_filters( 'pre_get_lastpostmodified', false, $timezone, $post_type );
	if ( false !== $lastpostmodified ) {
		return $lastpostmodified;
	}

	$lastpostmodified = _get_last_post_time( $timezone, 'modified', $post_type );

	$lastpostdate = get_lastpostdate($timezone);
	if ( $lastpostdate > $lastpostmodified ) {
		$lastpostmodified = $lastpostdate;
	}

	/**
	 * Filters the date the last post was modified.
	 *
	 * @since 2.3.0
	 *
	 * @param string $lastpostmodified Date the last post was modified.
	 * @param string $timezone         Location to use for getting the post modified date.
	 *                                 See get_lastpostdate() for accepted `$timezone` values.
	 */
	return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone );
}

更新日志

Versiondescription
4.4.0The $post_type argument was added.
1.2.0Introduced.

相关函数

Uses

  • wp-includes/post.php: pre_get_lastpostmodified
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/post.php: _get_last_post_time()
  • wp-includes/post.php: get_lastpostdate()
  • wp-includes/post.php: get_lastpostmodified

Used By

  • wp-includes/class-wp.php: WP::send_headers()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文