I think you forgot about the inherit post status. The default one in WP_Query
is publish.
You should also use =
instead of LIKE
, to avoid using LIKE '%%'
in the SQL query.
So try to add this:
'post_status' => 'inherit'
and
'compare' => '='
into your query arguments, to match the empty _wp_attachment_image_alt
string values.
Related Posts:
- Meta Query with date and time on the same Day before given time
- meta_query: check if number exists
- Check if searched number is within the post meta value
- How to add date_query to meta_query array
- get_posts query is taking about 40 seconds to execute
- Slow query when selecting with large meta query or post__in
- Use not custom fields in get_posts() meta_query?
- WordPress extremely slow when using get_posts with multiple meta_query relations
- When to use WP_query(), query_posts() and pre_get_posts
- WP Query Args – Title or Meta Value
- Meta query with string starting like pattern
- how to show posts that are missing a meta_value
- Does tax_query really beats meta_query in all situations?
- Query WooCommerce orders where meta data does not exist
- Execute a large WP_Query with many “AND” Meta_Queries?
- WP_Query using meta_query with relation OR and orderby meta_value doesn’t work
- Get_post() with meta_key when compare is a date
- querying with custom meta field with meta_query
- Order by two meta keys
- multiple meta key but get server load is very high
- A WP_Query that will look for posts after 2 weeks ago OR with a certain meta value
- Function to check if author has posted within the last x days
- Wp_query order by multiple custom fields?
- Order by meta_key in custom post type doesn’t affect the query
- Use meta_query to display events by date in custom field
- How to show recent and upcoming birthdays using meta_query
- Order Posts by meta value AND published date
- Using WP_Query and WP_Meta_Query Outside of WordPress
- If two first numbers exist in wp_meta_query value
- Create a sitemap without a plugin – get parent pages only?
- WP_Query on custom field and order results
- get_posts – find out if querystring was crap and fallback is used
- Creating query to show which editor (classic or block) was last used to edit a post/page
- Tax query clause inside a meta query clause?
- Return Taxonomy/Term Information with Posts (WP_Query/get_posts)
- Optional Meta Query
- How do I make a meta_query OR relation work? [closed]
- Weird orderby => post__in issue
- Meta_query on same meta key, with diffrenct values
- Can we return all category (not post) with Custom Query Filter? [closed]
- Extend product search with meta in WooCommerce
- how to make members list directory through wordpress post custom meta key.
- get posts by meta_key from inside key of post meta
- Help optimizing slow WP_Query with meta_query
- Conflict with get_posts and the_content
- 2 weeks ago from meta query meta value
- WP_Query with meta_query dosen’t return results
- How to show more post at a given category?
- Get posts by list of post IDs ordered by those IDs?
- Array as ‘key’ in WP_Query
- Reset WordPress Post Query to default
- Is it possible to query a custom field where the value is between two fields?
- How to provide meta_key array to wp_query?
- Searching for meta_key returns 0 posts
- Use WP_Query or query_posts() or get_posts() for optimizing a site?
- Specify strict ‘order by’ in WordPress query
- How to set up hierarchical relationships without using plugins / meta query
- Meta query compare for ID’s greater than specific ID
- Is it possible to add relation between meta_query and tax_query?
- WP_User_Query and user posts
- Show single posts date, in a page of posts
- WP_Query Class custom field parameters
- Why always one post missing
- meta_query where the meta value is not the post title
- Order WP_Query by meta_key priority when ‘OR’ relation used for multiple meta values
- Why my query is not “Main_query”?
- Facing problem with tax_query results
- How do i create a custom post query when the meta value is an array?
- meta_query with meta values as serialize arrays
- WP Query – grouping posts by same meta key, adding together values from another key
- Woocommerce Get Orders By Meta Value
- meta_query is overriding default search
- Multiple WP_Query args combinations according to post type
- WP_Query multiple value not working
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- Query for current post
- WP_User_Query Orderby Not Working
- Unusual high query of user meta data
- Very slow query generated getting meta data from posts
- WordPress Query optimaization for slow query
- Meta query doesn’t remove placeholder escape before query
- get_posts query caching?
- WP Query Meta Query
- Query custom meta value – post view and date meta
- How can I modify standard search query to include also ACF custom fields values?
- Custom WP_query and integrating into theme file
- WP_Query – show posts where meta value and user_email match
- Best way to Order Post in Home without a plugin
- WP_Query using meta_query with LIKE doesn’t return what it should
- Is there any difference between below WP_Query code snippets?
- Both WP_Query and get_posts returning 1 post
- Return a single custom post from multiple meta queries
- query post based on comparison
- Including ‘cat’ => $cat breaks meta_query
- Query string form $_GET[‘value’] is not working as meta value in wp_query
- WP_Query orderby not working on custom post_type
- 294 Queries on Mainpage of WordPress
- Query custom post types by meta field in a term from custom taxonomy
- How do I have multiple metaqueries inside one wordpress query
- Display only posts with thumbnails