Script doesn’t trash custom post types. Instead it duplicates the post and generate new versions in the trash August 11, 2022 by Tarik Billa The $id variable is never set. Use this instead: wp_trash_post( $postid );