I have W3 Total Cache installed and working, except that it does not correctly flush my category pages on posting or updating a post. I would like to do this automatically.
Within my WordPress theme I have several category pages and they are titled category-green-widgets, category-blue-widgets etc.
Some, eg category-widgets, can pull in category-red-widgets AND category-blue-widgets (I coded it this way). I need to dump all of the categories because of this, not just the ones the post belongs to.
As a start, I’m thinking this code might work to get the post’s categories:
/* Flush category pages */
function category_cache_flush_on_post( $post_id ) {
if(function_exists('w3tc_pgcache_flush_post')){
$post_categories = wp_get_post_categories( $post_id );
foreach($post_categories as $c)
w3tc_pgcache_flush_post($c[0]);
}
}
add_filter( 'save_post', 'category_cache_flush_on_post', 10, 1 );
So how do I dump the cache for ALL of the categories on updating or posting? What is the W3TC call for that?
on the page cache settings tab be sure that “Post terms pages” option is checked.