I believe that a relatively simple meta_query
would do it.
$args = array(
'post_type' => 'post',
'meta_query' => array(
array(
'key' => '_gallery_image_ids',
'value' => '',
'compare' => 'EXISTS'
)
)
);
$query = new WP_Query( $args );
Reference:
http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
Related Posts:
- Display images with same specific value?
- Is it possible to query all posts that don’t have an attachment?
- How to paginate wordpress [gallery] shortcode?
- How to get Page/Post Gallery attachment images in order they are set in backend using WP_Query()?
- Count the number of images uploded on the website
- How to paginate attachments in a secondary query as gallery?
- How do I exclude all images from a wp_query?
- Get attachment by slug
- get images attached to post
- How to display images in related posts?
- post thumb nail
- query attachments of parent page if attachments of current page are smaller than …
- wp_query for displaying attachments with a tag
- WP Query search for attachments and their exact title
- Gallery shortcode numerical sorting
- Better wordpress attachment query than this
- How to add WordPress featured image via SQL
- Display all attached image of every post of custom post type and link to original post
- Insert images into wordpress post with a query
- WP_Query: attachment image in “full” size?
- Change database image location for transportability
- WP query retrieve the src of attached image
- Trying to use “Medium” featured image for custom post type on home page
- wp_get_attachment_image not to get the post_thumbnaill
- How To Query All Attachment Images Found In Post Galleries
- Some images not being returned with wp_get_attachment_image
- Pull Instagram images into an existing loop?
- Way to include posts both with & without certain meta_key in args for wp_query?
- How to trigger 404 for custom query var?
- Can I load posts via Ajax?
- How can I use WP-CLI commands without –allow-root
- Calling a wp_query $posts causes a 500 error
- WP_query taxonomy + get all posts with two terms from same taxonomy
- How do I create my own nested meta_query using posts_where / posts_join?
- meta_query not working properly
- Best Practice For Querying Grandchildren?
- Using tax_query reverses my post_type argument in a custom WP_Query
- creating wp query with posts with specific category
- $wp_query->current_post restarts from zero on paged pages
- wp_get_post_terms of cpt but not duplicates if they are used more than once in the loop
- How to prevent queried posts from being added to cache?
- How to make orderby ‘meta_value_num’ OPTIONAL?
- How to do a query on custom taxonomies that is uncategorised?
- How can I query posts with newly uploaded images?
- Conditional arguments WP_Query for post custom fields
- Random loop with code to prevent duplicate output returns no output at all from time to time
- Single meta_query query using OR instead of AND in request’s WHERE statement
- How to change the target size of images clicked on in WordPress standard gallery
- How to choose between hooking into per_get_posts or into parse_query
- Woocommerce returns Product post_status as published even tho it is in status draft
- remove query arg from url after set query
- How to loop for every result found in the_content() when using the search query?
- How can I fix: “Notice: Undefined offset: 0”?
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- Order By table field comment_status in WordPress > 4.0
- Slow WP_Query for custom post type
- WP_Query Pagination on multiple-loop page breaks WP or doesn’t show up
- Using hook to use DISTINCT in a wp_query
- Overwrite YoastSEO meta-tags with another page’s [closed]
- Import wp users via one click demo option
- How to restrict the search fields for a specific post type
- Slow queries on a huge database
- Pagination links missing for first link (1) and previous button? How to get pagination links to work?
- Query with relation and one without relation using multiple taxonomies?
- Automatically Query Parent Taxonomy
- Shouldn’t I be able to modify the main query by this filter?
- WP Query crashes on more than ~ 2000 posts
- different for loop if screen resolution < 1000px
- insert value from html into data base with wordpress
- Debugging wp_query orderby for taxonomy
- Get all posts which was posted on X Days WordPress
- Pagination is not working with custom query inside a homepage template
- How to load a script code only in posts?
- Display posts with specific value first in query
- wp_query comment and meta query
- I need to run a AJAX Fuction from within a WP_Query but only works on first item
- How to change tag based on metabox value within $wp_query
- What’s missing in this wp_query and meta_query
- Tax Query on product_cat using NOT IN as operator does not exclude that category
- How to use the Term Object from a custom select field in a query
- Random users always showing same 8 users
- whether a nonce is required for get type and get_query_var?
- Wp-query and column blocks
- How to query users by post count no less than 10
- Display 3 levels of categories on page
- Showing most popular post of week
- Related Post by Tags Code
- Display three sequential posts on each page load, without repeating previous
- Find by post_meta, then sort by post_meta, then sort by date (wp_posts)
- Optimising amount of calls to custom fields
- The sorting of posts by a meta_query with two keys fails while separated as single queries it works
- Hierarchical List Pages as a table
- WP_Query with several meta_query-statements and order by meta_value
- Second wp_query doesn’t appear to be working
- difference between methods of query
- post__in not recognizing multiple IDs
- Related posts with WP_Query
- I want to place a post before all others from an ACF boleen field
- How to put posts with some taxonomy on top of others in `pre_get_posts`
- wp_query, calculate with two dates when ‘key’ is text format