Thanks for @dunc and @helgatheviking I got the answer. Here’s my code. You need the post type declared, otherwise it resorts to “post”. I also couldn’t do this unless I put meta_key and meta_value in a ‘meta_query’ multidimensional array.
$args = array(
'post_type' => 'tsa_events',
'meta_query' => array(
array(
'key' => 'slideshow_image',
'value' => array(''),
'compare' => 'NOT IN'
)
)
);
EDIT: you can also structure your query this way:
$args = array(
'post_type' => 'tsa_events',
'meta_key' => 'slideshow_image',
'meta_value' => array(''),
'meta_compare' => 'NOT IN'
);
Related Posts:
- Upcoming Event: How do I sort database by custom date field, but ignore past dates?
- Display posts where date field matches current month?
- WP_Query – Order results by meta value
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Can I query custom meta data through WP_Query
- Meta Query with AND & OR?
- How do I search an array stored in a custom-field using WP_Query?
- Group posts by custom field
- Order Posts by Closest Numeric Values
- 2 orderby in wp_query with 2 custom fields
- Order posts by custom field and if custom field is empty return remaining posts
- Can serialized arrays in DB be matched against serialized arrays with meta_query?
- How to get a meta value from all post
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Compare meta_query decimals not working right
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- Calling Specific Pages with wp query Part II
- Using OR in WP_Query negates the “NOT EXISTS” compare
- WP_query : meta_key with custom rule for specific value
- How can I combine meta_query queries?
- How to filter a dd/mm/yyyy date from a custom field in a query
- Using WP Query to search by multiple meta fields
- Sort by posts that have a featured image?
- WP_Query display next custom post from today’s date
- Order by value in serialized custom field
- $wp_query meta_key naming issue [closed]
- Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
- Meta_query and numeric comparison [closed]
- How do I exclude posts by custom field value?
- wp_query to find posts by year and month
- Adding Custom Fields to Search
- Calling custom fields for pages (not posts)
- Duplicate posts being displayed when querying Custom Fields
- Multiple relationships in a query
- Loop to display random posts only if a custom field matches category
- WP Query Returning All Posts
- How do I use wp_query for WordPress search?
- Meta query with timestamp using WP_query
- how do i remove posts from a WP_Query so the pagination is right?
- Conditional custom field query
- Order query by meta_value with multiple custom fields
- get_posts that match a user-specified value on a page
- Accessing loop functions (e.g the_title or the_content) from post ID
- Orderby is working with one query but not with other
- Order by empty custom field
- Is there a better way to list all database terms alphabetically?
- Change the main loop WordPress impact on the server?
- custom-meta-box checkboxes from loop won’t save
- How to show a post if was published less than two hours ago?
- Custom WP_Query for WordPress Search Results with meta_query
- Meta Query And/Or
- Custom Fields – How to create a list from multi-line entries of a single value
- how to make nsfw post with thumbanil
- Efficiently sort only certain categories by custom field
- Can I access a post meta field before the loop?
- Passing meta_box string to post__in?
- Displaying page image in the footer automatically
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- meta_value and meta_key filtering returning no posts [closed]
- Show image if author meta (profile fields) exists outside loop
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- WP ForLoop to compare meta information of posts to determine what post to display
- ul list with only as many li’s as filled custom fields
- Loop through incrementing custom fields
- do_shortcode close
- Search Results Page – Displaying Custom Meta Fields
- Meta query relation ‘OR’ not working as expected
- The best way to collision check in WP
- Interrogate a page within a loop to check template type or custom meta data (Pages vs Posts)
- Custom Query Fields – Altering Meta Value
- Multiple Custom Field Query
- How do I list a custom field and custom taxonomies for each result in a loop?
- How to show content of custom fields in search results?
- Custom field outside the loop and inside an array
- How to update custom field of a posts in a particular category
- How can I modify my meta_query to work with prices that are stored in the database that contain dollar signs and commas?
- get_field values for each post on home page using wp_add_inline_style
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- User Filter Options on Archive Page
- sorting in wp query based on custom field value
- Custom meta boxes – add php code inside?
- get wordpress post loop by meta box date
- WordPress query in which condition uses custom field
- WordPress loop add heading before first of type
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Error in WP Query. If variable is empty it is displaying previous post value
- Metabox value for post loop?
- WP_Query a custom field value bringing back 0 results
- Loop through multiple custom fields with increasing number
- WP_query returns error when used for custom widget
- WP Query multiple select form – meta_query help
- How to Order Posts by Custom Fields?
- WP_Query based on multiple metadata comparisons
- Show posts containing or not custom field
- Filtering posts by WORD in custom field
- Retrieve IDs from custom field, count and display results differently according to count
- Display agents (custom post type) alphabetically, except one who always shows last
- Pagination not displaying correct number of pages
- Custom field not showing
- Order by a meta field in query loop