Script doesn’t trash custom post types. Instead it duplicates the post and generate new versions in the trash

The $id variable is never set. Use this instead:

wp_trash_post( $postid );

techhipbettruvabetnorabahisbahis forumueduedueduedueduedueduedueduedu