Basically I have so many images associated with custom post type that I need to be able to safely delete all related media on removal from trash.

Is there a safe way of doing this?

1 Answer 1


Is your post to image association custom?

If not attachments should be automatically deleted by Wordpess. If the connection is custom, Wordpress provides a delete_post action that fires before and after a post is deleted, it will pass the ID of the post so you can use that to delete all custom content associated with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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