You can check status instock
only if meta key _stock_status
exists.
Something like:
'meta_query' => array(
array(
'key' => '_stock_status',
'value' => 'instock',
'compare' => '=',
),
'relation' => 'OR',
array(
'key' => '_stock_status',
'value' => '',
'compare' => 'NOT EXISTS'
),
)
Note: Code is not tried or tested, so check for any syntax errors
Related Posts:
- Query all posts where a meta key does not exist
- Meta query with boolean true/false value
- Get post with multiple meta keys and value
- How Do I Use WP_Query to Run This Database Query as Search Result?
- Can’t sort order of wp_query with 2 meta keys
- Woocommerce query specific product from specific category
- WordPress Orderby Numeric Value Not Working
- orderby in custom WP Query does not work
- Display custom post type from dynamic custom field
- changing meta value and meta key of price field
- Woocommerce search pagination not working
- WordPress request fiter order by related post’s post_title
- Sort posts in loop by the WooCommerce Membership of the author
- Displaying a div from an assigned meta_value when on a page
- How to get specific post meta by title or id
- $post->post_meta not pulling any post in wordpress/php
- WP_Query of custom post type sorted by meta_key has unexpected results
- Returning a custom content types with meta values
- Get all post from a post type
- WP_Meta_Query object with conditionals
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- After inserting new post with wp_insert_post() the post is not visble to WP_Query, but the same WP_Query works for post inserted from wp-admin panel
- Use WP_query to match post types based on custom field values
- How to sort by multiple values in a nested WP_Query
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- How to get post by meta value
- How do I get all authors posts of a custom post type outside loop
- add action save post type and update post meta woocommerce
- Linking posts together with Advanced Custom Fields “both ways”
- How to get Current week and current date record wp query
- How to get post meta for custom post type and taxonomy
- get_post_meta for Custom Post Type ( CPT )
- CPT or Custom Table for Repository of Serial Numbers
- Complex strcuture as CPT or taxonomy for use in woocommerce product variations [closed]
- WordPress custom post type
- Custom Post Type meta oembed html output resulting in WSoD
- Values inside a custom field to determine which category posts to display
- Querying meta values within an array
- Create a WordPress Database query to find users who purchased specific product through WooCommerce [closed]
- Pre defined checkbox / radio button state based on value stored in ACF fields in checkout form WooCommerce
- I am having a problem with fetching product data in the Gutenberg block editor
- Quering a post object based on another related post object
- Combining sorted and random CPT
- How to add post_type=value when editing that post type in the WordPress admin?
- Insert Multiple Post with Same Publish Button
- Display CPT posts based on specific taxonomy
- how to get URL of media uploaded to WordPress via media_handle_sideload()
- Update CPT post meta with update_post_meta and cron job
- Can’t query tag and post_type at the same time
- Setting proper query for multiple custom admin filters
- Custom meta box data array: foreach not working correctly?
- Undefined Variable – Custom Post Type Meta
- shortcode to show custom post types by category
- Unable to retrieve any posts of CPT in wp-admin
- WP_Query: include custom post type only with specific meta value
- Pagination on a custom post type loop
- How to display product subcategories into my custom post type single page
- Ordering posts in Search & taxonomy by post_meta
- showing custom post types of a certain category only
- Insert post metadata for all posts in CPT at once if metadata no existent
- WP_Query orderby modified to include custom meta changes
- WordPress custom loop filter by meta_key and value with serialize data
- Returning a list of custom post types excluding those without a specific meta_value
- query private custom post type
- Query/list all terms and their custom post count
- Linking to the most recent post in a Custom Post Type
- Show the same Article Available in Other Categories
- how to delete all users and posts based on ‘user_meta’?
- How to make sure content doesn’t display if selection is empty
- Filtering WP_Query Dynamically on the Front-End
- Populate dropdown from one custom post type inside another custom post type
- Show one item per category of a custom post type
- Why get_posts() not returning only selected category posts from Custom Post Type?
- Storing posts from query and accessing later via AJAX call
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Meta Key Value in current-user-only loop
- Archive for custom taxonomy lists all posts instead of current taxonomy
- Genesis filterable portfolio isotope [closed]
- Get post from custom post type order by two taxonomies
- Query custom post type with tags
- How to check if user meta field is empty in conditional else statement
- wp_query check if integer exists in custom field’s array
- How to set YouTube video as featured image?
- convert custom query to wp_query
- Wrong request query on cpt and tax
- Notice: Undefined index: error and understanding wordpress
- Previous/Next Link by Meta Value in CPT
- Show custom post type filtered by category
- Randomize Posts. Skip the first post in ascending order
- Creating a navigation menu of all posts of a custom post type and their children posts?
- Get custom taxonomies from multiple posts
- Custom Post Types. Are there any disadvantages/advantages in using a plugin to develop them?
- Pagination for Custom Taxonomy Page [duplicate]
- Filtering WP_Query
- Get posts between custom dates
- Search / Filter posts on Title/Content OR Tags
- Pagination on with query_posts in custom post type template
- Wp_query: sort by PHP variable
- WP_Query most viewed posts, in multiple Post Types, last 30 days, excluding a specific taxonomy term
- Custom-Posttype & Custom Taxonomy WP_Query