From 6ee4a055ee3ffba0af996e5145fd3e21f4f541cf Mon Sep 17 00:00:00 2001 From: Steve Lam Date: Fri, 14 Nov 2014 16:50:26 -0800 Subject: [PATCH 1/2] featured images are included with the posts. added filter for post_ids --- includes/export-functions.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/export-functions.php b/includes/export-functions.php index cbd7bf4..2150b87 100644 --- a/includes/export-functions.php +++ b/includes/export-functions.php @@ -159,7 +159,17 @@ function export_wp_plus( $args = array() ) { } } + // Get associated featured images + if( !empty( $post_ids ) ) { + foreach( $post_ids as $id ) { + if( $thumbnail_id = get_post_meta( $id, '_thumbnail_id', true ) ) { + $post_ids[] = $thumbnail_id; + } + } + } + // Allow third-party to filter posts + $post_ids = apply_filters('wp_export_post_ids', $post_ids); // Get the requested terms ready $cats = $tags = $terms = array(); From 3ac3c79b4e1b5f2e3d170f37699270c42ae6f27c Mon Sep 17 00:00:00 2001 From: Steve Lam Date: Sat, 15 Nov 2014 11:26:19 -0800 Subject: [PATCH 2/2] all attachments are included now instead of just featured images --- includes/export-functions.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/includes/export-functions.php b/includes/export-functions.php index 2150b87..b182768 100644 --- a/includes/export-functions.php +++ b/includes/export-functions.php @@ -155,17 +155,27 @@ function export_wp_plus( $args = array() ) { foreach( $posts as $post ) { $post_ids[] = $post->ID; } + + // Clean up + unset( $posts ); } } } - // Get associated featured images + // Get attachments if( !empty( $post_ids ) ) { - foreach( $post_ids as $id ) { - if( $thumbnail_id = get_post_meta( $id, '_thumbnail_id', true ) ) { - $post_ids[] = $thumbnail_id; - } + $attachments = get_posts( array( + 'post_type' => 'attachment', + 'post_status' => 'any', + 'post_parent__in' => $post_ids, + 'posts_per_page' => -1, + ) ); + foreach( $attachments as $attachment ) { + $post_ids[] = $attachment->ID; } + + // Clean up + unset( $attachments ); } // Allow third-party to filter posts