Skip to content

Instantly share code, notes, and snippets.



Last active Dec 16, 2015
What would you like to do?
Delete WordPress transient under the proper conditions
// delete featured coaches transient on coach save
function delete_featured_transient($post_id) {
// First we want to make sure that this is a real save, not simply an auto save
if ( !wp_is_post_revision( $post_id ) ) {
// now we declare our custom content type, because we only want to run this
// on the save of this type
$slug = 'coaches';
// this is where we actually make sure we're on the right type.
$_POST += array("{$slug}_edit_nonce" => '');
if ( $slug != $_POST['post_type'] ) {
// assuming we're on the proper type, set the transient name
$transient_name = 'featured_coaches';
// now delete the actual transient
// end delete_featured_transient
// now we hook that function into save_post and it's all set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.