From 29bbc891d6cf3d26fc1a9301142ee4c8d7d5e4ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Droz?= Date: Thu, 26 Apr 2018 19:14:28 -0300 Subject: [PATCH] wp_insert_attachment() returns 0 **unless** the 3rd parameter is set to return a WP_Error --- class-wxr-importer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class-wxr-importer.php b/class-wxr-importer.php index 19afbec..c453fb4 100644 --- a/class-wxr-importer.php +++ b/class-wxr-importer.php @@ -1059,7 +1059,7 @@ protected function process_attachment( $post, $meta, $remote_url ) { } // as per wp-admin/includes/upload.php - $post_id = wp_insert_attachment( $post, $upload['file'] ); + $post_id = wp_insert_attachment( $post, $upload['file'], 0, TRUE ); if ( is_wp_error( $post_id ) ) { return $post_id; }