[wp-trac] [WordPress Trac] #63614: pre_get_lastpostdate filter
WordPress Trac
noreply at wordpress.org
Mon Jun 23 03:13:16 UTC 2025
#63614: pre_get_lastpostdate filter
-------------------------+-----------------------------
Reporter: gddrt | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version:
Severity: minor | Keywords: has-patch
Focuses: |
-------------------------+-----------------------------
This was suggested long ago in #40789, but the original reason for that
ticket was to modify a post type, so it was closed because a different
solution had resolved the problem.
However, this filter would also be useful for avoiding the massive
performance problems of `get_lastpostdate()`. Regardless of which timezone
argument you pass to `get_lastpostdate()`, it queries the unindexed
`post_date_gmt` column of wp_posts, which requires a full scan of all
published posts of the given post type. This could be tens of thousands of
rows for large sites.
It would be better if `_get_last_post_time()` used the `post_date` column
instead, but I understand that would be a breaking change (although, I
think a trivial one). A `pre_get_lastpostdate` filter with a short-
circuit, like the patch offered in #40789 would at least allow power users
or a plugin to provide a more performant workaround.
There is a `get_lastpostdate` filter, but it runs after the expensive
query so it does not help.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63614>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list