Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Automatically purge object cache
<?php
/*
Plugin Name: Automatically purge object cache
Description: Automatically purge object cache on post changes.
*/
foreach ( array( 'trashed_post', 'delete_post', 'edit_post', 'publish_page', 'publish_post', 'save_post' ) as $hook ) {
add_action( $hook, 'wp_cache_flush' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment