Make WordPress Core

Opened 7 years ago

Closed 5 years ago

Last modified 5 years ago

#40789 closed enhancement (duplicate)

pre_get_lastpostdate filter

Reported by: toddlevy's profile toddlevy Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7.5
Component: General Keywords:
Focuses: Cc:


This is line 5530 of

Currently, there is no way to filter get_lastpostdate in advance of it calling _get_last_post_time.

This creates situations where it's impossible to filter/modify the default post type because...

a) get_lastpostdate is called without the $post_type argument (e.g. as happens in get_lastpostmodified and sometimes in 3rd party plugins), and

b) The _get_last_post_time function that gets called doesn't allow $post_type to be filtered as best I can tell

If you take a look at get_lastpostmodified you can see the pre_get_lastpostmodified filter, which is great and would solve this problem.

Suggested enhancement is to add a similar pre_get_lastpostdate filter for get_lastpostdate with the same naming convention and functionality.

Something like this...

function get_lastpostdate( $timezone = 'server', $post_type = 'article' ) {
  $lastpostdate = apply_filters( 'pre_get_lastpostdate', false, $timezone, $post_type );
  if ( false !== $lastpostdate ) {
     return $lastpostdate;

  $lastpostdate  = _get_last_post_time( $timezone, 'date', $post_type );

  return apply_filters( 'get_lastpostdate', $lastpostdate, $timezone );


Thank you for your consideration of this idea.

Change History (2)

#1 @keraweb
5 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

The patch in #40790 would fix this ticket as well.

#2 @desrosj
5 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.