Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author ramon fincken

    (@ramon-fincken)

    yes but only if they are attached to the post (so not when added in the media library)

    Plugin Author ramon fincken

    (@ramon-fincken)

    	/**
    	 * Actually deletes post and its attachments
    	 */
    	private function delete_post_and_attachments($post_id, $force_delete) {
    		$atts = get_children(
    		[
    		 'post_parent' => $post_id,
    		 'post_status' => 'inherit',
    		 'post_type' => 'attachment'
    		 ]
             	);
    		 if ($atts) {
    		 	foreach ($atts as $att) {
    		 		// Deletes this attachment
    		 		wp_delete_attachment($att->ID, $force_delete);
    		 	}
    		 }
    
    		 // Now delete post
    		 wp_delete_post($post_id, $force_delete);
    	}
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Does the plugin delete the media attachments too?’ is closed to new replies.