get_lastpostmodified

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

Description

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

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.

Returns (string)

The timestamp.

Parameters (2)

0. $timezone — Optional. (string) => 'server'
The timezone for the timestamp. See get_lastpostdate() for information on accepted values. Default server..
1. $post_type — Optional. (string) => 'any'
The post type to check. Default any..

Usage

  1. if ( !function_exists( 'get_lastpostmodified' ) ) { 
  2. require_once ABSPATH . WPINC . '/post.php'; 
  3. $timezone = 'server'; 
  4.  
  5. // Optional. The post type to check. Default 'any'. 
  6. $post_type = 'any'; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = get_lastpostmodified($timezone, $post_type); 
  10.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/post.php  
  1. function get_lastpostmodified( $timezone = 'server', $post_type = 'any' ) { 
  2. /** 
  3. * Pre-filter the return value of get_lastpostmodified() before the query is run. 
  4. * @since 4.4.0 
  5. * @param string $lastpostmodified Date the last post was modified. 
  6. * Returning anything other than false will short-circuit the function. 
  7. * @param string $timezone Location to use for getting the post modified date. 
  8. * See get_lastpostdate() for accepted `$timezone` values. 
  9. * @param string $post_type The post type to check. 
  10. */ 
  11. $lastpostmodified = apply_filters( 'pre_get_lastpostmodified', false, $timezone, $post_type ); 
  12. if ( false !== $lastpostmodified ) { 
  13. return $lastpostmodified; 
  14.  
  15. $lastpostmodified = _get_last_post_time( $timezone, 'modified', $post_type ); 
  16.  
  17. $lastpostdate = get_lastpostdate($timezone); 
  18. if ( $lastpostdate > $lastpostmodified ) { 
  19. $lastpostmodified = $lastpostdate; 
  20.  
  21. /** 
  22. * Filters the date the last post was modified. 
  23. * @since 2.3.0 
  24. * @param string $lastpostmodified Date the last post was modified. 
  25. * @param string $timezone Location to use for getting the post modified date. 
  26. * See get_lastpostdate() for accepted `$timezone` values. 
  27. */ 
  28. return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone );