Filter hook 'get_post_time'

in WP Core File wp-includes/general-template.php at line 2914

View Source

get_post_time

Filter Hook
Description
Filters the localized time of the post.

Hook Information

File Location wp-includes/general-template.php View on GitHub
Hook Type Filter
Line Number 2914

Hook Parameters

Type Name Description
string|int $time Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
string $format Format to use for retrieving the date of the post. Accepts 'G', 'U', or PHP date format.
bool $gmt Whether to retrieve the GMT time.

Usage Examples

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

function my_custom_filter($time, $format, $gmt) {
    // Your custom filtering logic here
    return $time;
}

Source Code Context

wp-includes/general-template.php:2914 - How this hook is used in WordPress core
<?php
2909  	 * @param string|int $time   Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
2910  	 * @param string     $format Format to use for retrieving the date of the post.
2911  	 *                           Accepts 'G', 'U', or PHP date format.
2912  	 * @param bool       $gmt    Whether to retrieve the GMT time.
2913  	 */
2914  	return apply_filters( 'get_post_time', $time, $format, $gmt );
2915  }
2916  
2917  /**
2918   * Retrieves post published or modified time as a `DateTimeImmutable` object instance.
2919   *

PHP Documentation

<?php
/**
	 * Filters the localized time of the post.
	 *
	 * @since 2.6.0
	 *
	 * @param string|int $time   Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
	 * @param string     $format Format to use for retrieving the date of the post.
	 *                           Accepts 'G', 'U', or PHP date format.
	 * @param bool       $gmt    Whether to retrieve the GMT time.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/general-template.php
Related Hooks

Related hooks will be displayed here in future updates.