Filter hook 'pre_get_lastpostmodified'

in WP Core File wp-includes/post.php at line 7502

View Source

pre_get_lastpostmodified

Filter Hook
Description
Pre-filter the return value of get_lastpostmodified() before the query is run.

Hook Information

File Location wp-includes/post.php View on GitHub
Hook Type Filter
Line Number 7502

Hook Parameters

Type Name Description
string|false $lastpostmodified The most recent time that a post was modified, in 'Y-m-d H:i:s' format, or false. Returning anything other than false will short-circuit the function.
string $timezone Location to use for getting the post modified date. See get_lastpostdate() for accepted `$timezone` values.
string $post_type The post type to check.

Usage Examples

Basic Usage
<?php
// Hook into pre_get_lastpostmodified
add_filter('pre_get_lastpostmodified', 'my_custom_filter', 10, 3);

function my_custom_filter($lastpostmodified, $timezone, $post_type) {
    // Your custom filtering logic here
    return $lastpostmodified;
}

Source Code Context

wp-includes/post.php:7502 - How this hook is used in WordPress core
<?php
7497  	 *                                       other than false will short-circuit the function.
7498  	 * @param string       $timezone         Location to use for getting the post modified date.
7499  	 *                                       See get_lastpostdate() for accepted `$timezone` values.
7500  	 * @param string       $post_type        The post type to check.
7501  	 */
7502  	$lastpostmodified = apply_filters( 'pre_get_lastpostmodified', false, $timezone, $post_type );
7503  
7504  	if ( false !== $lastpostmodified ) {
7505  		return $lastpostmodified;
7506  	}
7507  

PHP Documentation

<?php
/**
	 * Pre-filter the return value of get_lastpostmodified() before the query is run.
	 *
	 * @since 4.4.0
	 *
	 * @param string|false $lastpostmodified The most recent time that a post was modified,
	 *                                       in 'Y-m-d H:i:s' format, or false. 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.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/post.php
Related Hooks

Related hooks will be displayed here in future updates.