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]
- Get Posts in a Custom Post Type category
- Custom field values deleted when trashing custom post type
- Custom Queries: Joining On Meta Values From Two Custom Post Types
- Rest Api v2 orderby meta_key in custom post type
- How to query for posts (in hierarchical custom post type) that have children?
- bulk Update post_meta with default values
- Set meta_query only for specific post type
- Get the next event using date_query
- Custom Post Status Transition Issues With Get Post Meta
- wpdb custom post_type problem
- Pagination on category page with custom post types
- Show the same Article Available in Other Categories
- Show custom post type filtered by category
- Filtering WP_Query
- Custom post taxonomies as tax_query terms?
- get_post_meta not working on publishing
- Custom post type ‘articles’ ignores posts_per_page, reserved post_type?
- WP Query with categories only shows one post and ignores the category
- Can I display custom post types in home.php or need page template?
- WordPress wp_query() basic question about args
- Meta data (Tags and Categories) for Custom Posts not showing.
- Display different information of a custom post type
- Custom post type, custom taxonomy, query posts only from taxonomy (children of)
- How to get the post terms from a child taxonomy
- Pagination for search results of custom post type [duplicate]
- WP_Query get post from a category and from another post type
- Custom Plugin – Query CPT – Display Results
- foreach loop inside the loop creating duplicates in output
- delete duplicate meta_value with same post_id
- All blog posts are not showing up
- Search CPT Title AND Meta
- Custom post-type custom query – show all posts
- Custom Post type to Woocommerce Product type
- Using publish_{custom-post-type} hook for custom post type to update meta doesn’t work
- meta query condition don’t work
- Filter posts by their related field’s custom field
- Custom post type category returns null
- Query a Custom Post Type using SELECT that has ACF fields to compare dates
- Get meta values from parent post and save in child post
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- minimize wp_query call to database
- Custom post type meta fields missing on save_post_type
- sorting in wp query based on custom field value
- Custom Taxonomy not working front side Woocommerce
- WooCommerce breadcrumb display custom posts instead of product data
- WordPress loop add heading before first of type
- Only show current category post
- Custom Post Type shows pagination (w/404) or posts_per_page query, but not both
- WP_Query for CPT with filter by another WP_Query
- Is it possible to add query parameters on the archive page?
- Storing/querying custom date data
- Query Posts From Multiple Post Types
- Custom Post-type not returning the right child_of
- Random meta field from specific custom post type
- How do I hide single category post on my post page
- Issue On Listing Woocommerce Parent Tag List
- querying to custom field over ACF REST API
- WordPress custom field sorting, weird behavior: the latest post is at the end
- Default WordPress Query for a Specific Custom Post Type URL
- How do I add the “orange counter” next to a Custom Post Type?
- Dynamically count the number of custom post types associated to a custom taxonomy