wp_delete_attachment non
foreach ( $attachments as $attachment ) {
if ( false === wp_delete_attachment( $attachment->ID, true ) ) {
$file = get_attached_file( $attachment->ID );
$file = str_replace( "uploads", "upload-assets", $file);
wp_delete_file( $file );
}
}
Enthusiastic Eagle