This code deletes all attachments from the WordPress database. It creates a new WP_Query object containing all posts of the post type ‘attachment’, then iterates through them, deleting each one. Finally, it resets the postdata to ensure no conflicts.
Was this code snippet helpful?
YesNo