[wp-trac] [WordPress Trac] #27736: Save one query when inserting a new post
WordPress Trac
noreply at wordpress.org
Fri Dec 19 03:21:50 UTC 2025
#27736: Save one query when inserting a new post
-------------------------------+------------------------------------------
Reporter: ozh | Owner: pbearne
Type: enhancement | Status: reopened
Priority: normal | Milestone: 7.0
Component: Posts, Post Types | Version: 3.0
Severity: normal | Resolution:
Keywords: needs-patch | Focuses: administration, performance
-------------------------------+------------------------------------------
Comment (by peterwilsoncc):
Replying to [comment:13 westonruter]:
> Maybe a better approach would be to call `update_post_cache()` so that
when `wp_set_post_categories()` runs it has access to to the `post_type`
and `post_status` in the object cache?
The call to `get_post_type()` already primes the cache (via `get_post` via
`WP_Post`) so calling `update_post_cache()` will result in the same number
of queries, the location would just change.
However, looking at `wp_insert_post()` even with this change the post will
end up being queried with the call to `$current_guid = get_post_field(
'guid', $post_id );` so passing the data to `wp_set_post_categories()` may
not have an effect on the number of queries anyway.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27736#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list