From f2659c992f357afa00662ad7adedae60e722b9e9 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Mon, 4 Dec 2006 14:25:21 +0000 Subject: [PATCH] change post_parent on orphaned attachments. props ryanscheuermann. fixes #2681 git-svn-id: https://develop.svn.wordpress.org/trunk@4601 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wp-includes/post.php b/wp-includes/post.php index bea12cff66..36df770852 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -410,6 +410,8 @@ function wp_delete_post($postid = 0) { if ( 'page' == $post->post_type ) $wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_type = 'page'"); + $wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_type = 'attachment'"); + $wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $postid"); $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID = $postid");