Skip to content

Commit 68ee7f7

Browse files
author
Raphaël Droz
committed
support exporting attachments when specific post ids are requested (assuming the post whose ids were specified were not attachment themselves)
1 parent 1b40f23 commit 68ee7f7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/WP_Export_Query.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ public function posts() {
140140
private function calculate_post_ids() {
141141
global $wpdb;
142142
if ( is_array( $this->filters['post_ids'] ) ) {
143+
if ( getenv( 'WP_WITH_ATTACHMENT' ) ) {
144+
$attachment_post_ids = $this->attachments_for_specific_post_types( $this->filters['post_ids'] );
145+
$this->filters['post_ids'] = array_merge( $this->filters['post_ids'], $attachment_post_ids );
146+
}
143147
return $this->filters['post_ids'];
144148
}
145149
$this->post_type_where();
@@ -262,7 +266,7 @@ private function category_where() {
262266

263267
private function attachments_for_specific_post_types( $post_ids ) {
264268
global $wpdb;
265-
if ( !$this->filters['post_type'] ) {
269+
if ( ! $post_ids ) {
266270
return array();
267271
}
268272
$attachment_ids = array();

0 commit comments

Comments
 (0)