Delete post thumbnail relationships for deleted attachments. props scribu. see #10928
git-svn-id: http://svn.automattic.com/wordpress/trunk@12054 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5f9ac8a5fd
commit
529cc9244b
|
@ -2710,6 +2710,8 @@ function wp_delete_attachment($post_id) {
|
|||
/** @todo Delete for pluggable post taxonomies too */
|
||||
wp_delete_object_term_relationships($post_id, array('category', 'post_tag'));
|
||||
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_thumbnail_id' AND meta_value = %d", $post_id ));
|
||||
|
||||
$commentids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ));
|
||||
do_action( 'delete_comment', $commentids );
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->comments WHERE comment_ID IN(%s)", implode( ',', $commentids ) ));
|
||||
|
|
Loading…
Reference in New Issue