Hooks for trashing, deleting, saving, restoring custom post type

Two action hooks run when a post is trashed wp_trash_post before the post is trashed and trashed_post afterwards. These run for any post type including attachments.

See wp-includes/post.php

If you want to limit your function to a specific post type you need to run a check in you callback function.

function my_trash_action( $post_id ) {
   if ( 'custom_post_type' != get_post_type( $post_id )
       return;
     //Do Stuff....
}
add_action( 'trashed_post', 'my_trash_action' );

Leave a Comment