Delete Media With Widget
-
So I have this nifty little function that deletes media when a post gets deleted:
/** Delete Media Attahced to Post **/ function delete_associated_media($id) { $media = get_children(array( 'post_parent' => $id, 'post_type' => 'attachment' )); if (empty($media)) return; foreach ($media as $file) { wp_delete_attachment($file->ID); } } add_action('before_delete_post', 'delete_associated_media');
I was wondering if I could also hooking into something before the widget gets deleted so I can then get the associated media and delete it also.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Delete Media With Widget’ is closed to new replies.