From c66b957451e6958d664036b3c4bf75eee7b7dfb0 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 14 Jul 2016 11:07:29 -0700 Subject: [PATCH] Ensure meta queries work for snapshotted auto draft posts Props @PatelUtkarsh --- php/class-wp-customize-posts.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/php/class-wp-customize-posts.php b/php/class-wp-customize-posts.php index 4e904c7..59f5da3 100644 --- a/php/class-wp-customize-posts.php +++ b/php/class-wp-customize-posts.php @@ -842,6 +842,10 @@ public function insert_auto_draft_post( $post_type ) { 'post_date_gmt' => $date_gmt, 'post_modified' => $date_local, 'post_modified_gmt' => $date_gmt, + 'meta_input' => array( + // Dummy postmeta so that snapshot meta queries won't fail in \WP_Customize_Posts_Preview::get_previewed_posts_for_query(). + '_snapshot_auto_draft' => true, + ), ); $r = wp_insert_post( wp_slash( $args ), true ); remove_filter( 'wp_insert_post_empty_content', '__return_false', 100 );