获取上次修改任何帖子的时间戳。

原型

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

描述

服务器时区是默认值,是GMT和服务器时间之间的差异。 “博客”值恰好是修改上一篇文章的时间。 ‘gmt’是在GMT时间内修改最后一篇文章的时间。

参数

$timezone (string) (Optional)  时间戳的时区。有关可接受值的信息,请参阅get_lastpostdate()。

$post_type (string) (Optional)  要检查的帖子类型。

返回值

(string)  时间戳。

源文件

路径:wp-includes/post.php

<?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 );
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/get_lastpostmodified/