Forcing cache clean by code not working
-
Hi!
I’ve added this code to force cache cleaning when an specific CPT is created/updated:
function clean_cache_for_cpt( $post_id, $post, $update ) { if ( 'cpt' !== $post->post_type ) { return; } WPO_Page_Cache::delete_single_post_cache($post_id); } add_action( 'save_post', 'clean_cache_for_cpt', 10,3 );
But it’s not working, I cannot see the changes until I manually clean the cache.
The problem is that I have a custom query on a homepage to list specific custom posts but when I update any of them, the changes are not reflected until I force the cache to be cleaned.
I don’t want to set the homepage not to be cached, but I need to clear the cache for this CPT.
Any suggestion?
Thanks in advance, regards.
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Forcing cache clean by code not working’ is closed to new replies.