[wp-trac] [WordPress Trac] #63904: Add action hook when terms counts are updated
WordPress Trac
noreply at wordpress.org
Mon Sep 1 11:43:18 UTC 2025
#63904: Add action hook when terms counts are updated
------------------------------+-----------------------------
Reporter: LeonidasMilossis | Owner: SergeyBiryukov
Type: enhancement | Status: accepted
Priority: normal | Milestone: 6.9
Component: Taxonomy | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses: performance
------------------------------+-----------------------------
Changes (by SergeyBiryukov):
* owner: (none) => SergeyBiryukov
* status: new => accepted
* milestone: Awaiting Review => 6.9
Old description:
> With https://core.trac.wordpress.org/ticket/42522 and
> https://core.trac.wordpress.org/ticket/63562 merged and slated for 6.9,
> we have now achieved running the UPDATE queries for updating term counts
> only when we should, which is great.
>
> What we still lack though is the presence of a dedicated action hook that
> runs only during those operations. The name of that hook could be
> something like `update_term_count`.
>
> An example where this is needed is something we want to add in Yoast SEO
> where we need to update some database entries of our custom database
> tables and we need to do that only when a term count is updated.
> Considering that we're talking about an extra database query, we want to
> make sure that we only do that when a term count is actually updated and
> not with every update of terms/posts.
>
> One ''could'' use the `edit_term_taxonomy` action for this, while
> checking for the existence of the `$args` parameter, but this feels hacky
> and having a more canonical and dedicated hook for this probably makes
> more sense.
New description:
With #42522 and #63562 merged and slated for 6.9, we have now achieved
running the UPDATE queries for updating term counts only when we should,
which is great.
What we still lack though is the presence of a dedicated action hook that
runs only during those operations. The name of that hook could be
something like `update_term_count`.
An example where this is needed is something we want to add in Yoast SEO
where we need to update some database entries of our custom database
tables and we need to do that only when a term count is updated.
Considering that we're talking about an extra database query, we want to
make sure that we only do that when a term count is actually updated and
not with every update of terms/posts.
One ''could'' use the `edit_term_taxonomy` action for this, while checking
for the existence of the `$args` parameter, but this feels hacky and
having a more canonical and dedicated hook for this probably makes more
sense.
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63904#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list