How To Auto-delete Attached Media Files When WordPress Post Is Deleted?

WordPress allows you to upload and embed a variety of media file types like images, music and videos etc. But when a post is deleted, all attached files are left orphaned in your media library and since they are of no more use, they cause unnecessary load on your website.

Earlier we have discussed about deleting unattached images from your WordPress media library. We have also discussed about deleting original image files if their custom size is used inside your post content.

Now today in this lesson you will learn about automatically deleting attached files when any post or post type is deleted from your WordPress installation.

What all you have to do is install and activate the new Autoremove Attachments plugin and that’s it. There are no configuration options to set, upon activation the plugin automatically starts to work and removes child attachments when a parent post, page or custom post type is deleted.

But remember, before using this plugin you need to make sure that you don’t use same media files in multiple posts or you will end up missing post images in your WordPress website.

And if you need using same images over and over in addition to this plugin then you must re-upload them either from your admin area dashboard Media -> Add New page or by using ‘Add Media’ button present in WordPress visual editor.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.