I am very new in wordpress and I am currently developing a wordpress plugin, I just want to know if there is a wordpress plugin hook that will run when one or more file of wordpress media is deleted.



1 Answer 1


The delete_attachment action is fired when wp_delete_attachment() function is called to delete an item in the media library.

  • 1
    i already got the snippets but still your answer is correct. thanks by the way Apr 26, 2016 at 5:01
  • Regarding https://developer.wordpress.org/reference/hooks/delete_attachment/, it fires before an attachment is deleted, at the start of wp_delete_attachment(). So it is risky if you delete the file but WordPress doesn't due to an error or something.
    – kodfire
    May 14, 2022 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.