As probably there is not so many unpublished posts with images, You could exclude them from Your WP_Query, adding:
'post_parent' => '-12,-34,-56'
this would add overhead of only one query grabbing id’s of these posts
Related Posts:
- WP_Query by post ID doesn’t work if post is in custom post_status
- How to Get All Posts but the Private ones?
- How can I style future post?
- How to display future posts – modified query still yields 404
- Can’t get drafts with WP_Query using post_status parameter
- Wp_query Add specific pending posts
- Show scheduled posts in main loop but not in WP_Query?
- wp_query ignoring custom post_status
- Does the WP_Query ‘private’ argument for post status only apply to privately published content?
- Why won’t draft listings appear for non-admins?
- WP_Query will not display draft posts
- WordPress post_status and meta_query
- Give attachments an archive page, and exclude unattached ones
- Broken? WP_Query and “attachment” as a post type
- Order by DESC, ASC in custom WP_Query
- Exclude or Include category ids in WP_Query
- Secondary Sort (fallback) for WP_Query
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Query Posts in a Predefined Order
- How to stop wordpress to make the default query?
- How to make an activities stream mixing posts and comments?
- WP_Query based on URL parameters
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- Order posts ascending with number in title
- using wp_query to return posts w/ comment count > 0
- Order by meta_key in custom post type doesn’t affect the query
- Is there a PHP function that can match anything after the given URL, so my IF statement will work in each instance?
- why do drafts return as part of wp_query?
- Add a default meta_value to new posts
- WP query exclude post within the last month / only show over 1 month old
- WordPress query for most recent posts from multiple categories
- How to use Meta Value Compare in WP_Query For Max and Min numbers
- WordPress documentation – WP_Query arguments
- Using apply_filters(‘the_content’, $custom_query->post_content) alters output
- WP_Query Date Query After Minus Hour AND minus minutes
- Shortcode to show thumbnail and link for 3 random posts
- wp query template tags not working
- Get number of authors
- How to display upcoming events by dat with Modern Events Calendar Lite
- How to Filter Posts by Custom Fields?
- How can I display a custom field from all posts and order them individually from their parent post
- pagination with ‘no_found_rows’ => true,
- How to get all product attributes for filters in WooCommerce?
- Fetch Record based on meta key dates
- How can I display list of all posts from a specific author, with publish dates in the future, on an author archive page (author.php)?
- Custom posts visible in admin, but truncate in public
- Query posts from category A, and from either category B or C
- meta_query not working as expected
- wp_query with parameters
- Query posts with “non set” meta value
- Add filter post_where and passing post_type argument
- WP_Query infinite Loop
- Limiting number of related posts
- Ordering a mysql style datetime stamp with meta_query
- Advanced WP Query and/or
- 2 wordpress loops showing 1 post from same post type – how to avoid showing the same post?
- WP Query – order posts by meta field first and then order the rest
- Reusing content from front page on sub page
- Get Child Page IDs by Parent ID
- Wildcard search in WP Query
- Pagination works in custom query loop but it doesn’t work in shortcode
- Especific order by Custom Field Values in WP_Query
- Create a notification for post field
- date_query is showing duplicate results
- How to query posts for custom post type with featured image for first 2 post?
- Why is get_the_excerpt returning full content
- How to avoid filling up an array each time I run a WP_query?
- How to SQL query posts IDs by categories AND authors?
- Randomly pick one testimonial post
- Date not appearing in custom query
- Custom post type – filter content by custom meta box content
- Trying to output content from page, works locally but not online
- Admin: Custom Query Returning Permissions Error
- wp query remove posts from query then update max pages and posts found
- Combine relationship posts with existing wp_query
- Slick slider for post doesn’t display anything
- What is the equivalent WP_Query of a SQL Query?
- Count post meta entries
- use mysql variable in a $wpdb->query to reindex a column?
- How to get only present and past posts with post_date
- wp_insert_post with ACF Fields and WP Meta Query returns no rows until update
- Query WP Posts, then list the taxonomies from those posts
- Query post with content only
- Search with WP_Query, but ignore href URLs in anchor tags?
- Displaying Pages in Nav Sub-Menu with Specific Taxonomy Terms?
- Is meta_key used for ordering, filtering, or both?
- compare for multiple meta values for same key in wp_query
- Taxonomy Terms That Don’t Exist Display Results
- Why is my query not giving results?
- Wrote a WP Cron Plugin and it triggers a fatal error upon activation
- Add pagination to table generated by wp_query
- Adding a Theme Customizer Control for Posts_Per_Page
- using next-page and previous page inside a wp_query
- Custom query from all posts & all child page from one parent page?
- wp_query conditionally get posts
- restrict posts per page
- the_excerpt() not working in custom archive
- WordPress extremely slow when using get_posts with multiple meta_query relations
- Refresh wp_query with no changes
- Search results stuck on page 1