diff --git a/wp-includes/post.php b/wp-includes/post.php index d9d48a56fe..94ec8f2c50 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -4719,10 +4719,15 @@ function is_local_attachment($url) { function wp_insert_attachment( $args, $file = false, $parent = 0 ) { $defaults = array( 'file' => $file, - 'post_parent' => $parent + 'post_parent' => 0 ); + $data = wp_parse_args( $args, $defaults ); + if ( ! empty( $parent ) ) { + $data['post_parent'] = $parent; + } + $data['post_type'] = 'attachment'; return wp_insert_post( $data );