I’ve got multiple custom post types registered via a plugin and one of them is used as a precursor for multiple other queries. In an attempt to reduce queries throughout the site, I’ve decided to include the one CPT, we’ll call it post_type_x
and some of it’s post_meta
data in wp_cache
.
Everything is working exactly as I want it to – the data I’m placeing in wp_cache
is available for me when I need it, whenever I need it, etc and I’ve managed to reduce an entire query for some of the more complex pages on the site.
However, I’m wondering about a very ‘edge’ case:
When I am creating a new post_type_x
post – any users currently on the site will already have their wp_cache
set and if the new post_type_x
fits the requirements of the original check that determines which post_type_x
posts to add via wp_cache_set()
it won’t get added for users currently browsing.
This in itself isn’t actually a problem as any newly added post_type_x
won’t need to be included for your typical user of the site as soon it’s created. These posts will usually be created weeks or even months before standard users needed to access them and by that time they’ll have visited the site multiple times and they’ll have their cache re-set.
However, the one segment of people that may need to see new post_type_x
posts loaded into the wp_cache
as soon as they’re created would be administrators. Not just as soon as they’re created but rather have the post_meta
in wp_cache
updated as soon as they make changes.
So, what I’m wondering… …is there a reliable hook/action within WP I can use that runs immediately AFTER the add_action( 'save_post_post_type_x', 'post_type_x_save_function', 1, 2 );
That way I can be sure that the admin user has their wp_cache
set as soon as they’ve implemented a change to one of the post_type_x
posts.