Products variations are a stored as a different post type, product_variation
, so you have to add that post type to the query:
'post_type' => array( 'product', 'product_variation' )
Also, you could try to use WooCommerce specific functions, like wc_get_product_ids_on_sale()
, wc_get_products()
and so on, they could make your life easier when coding for WooCommerce.
Related Posts:
- Find out total number of pages in global query on archive page?
- Resetting post data to previous loop in nested loops
- Order by multiple meta key and meta value [closed]
- Is it possible to completely stop WP_Query retrieving posts?
- Order by optional meta key?
- Make loop display posts by alphabetical order
- WP_query to get the first two latest posts, then another loop to get the next three
- Why is WP_Query not working with category_name?
- ‘Trying to get property of non-object’ when using WP_Query with ‘fields’ => ‘ids’
- Displaying several specific pages using WP_Query()
- WP-CLI How to generate a list of posts with corresponding meta values
- Query to return maximum of one post per author
- Get attachment by slug
- RSS feed with specific keyword
- Get All IDs Of A Post Type Using WP_Query
- Warning: urlencode() expects parameter 1 to be string, array given
- Group posts by custom field
- Multiple endpoints in one URL
- How to get the posts published in last two days using WP_Query?
- getting posts and number by specific meta value in multiple meta
- How to query using a combination of custom_field values?
- All sticky posts are returned in custom query
- Get attached media only
- Can not switch the queried post in pre_get_posts hook
- how to fire join query with post_meta
- Show one post per author and limit query to 8 posts
- Get term by custom term meta and taxonomy
- SELECT * FROM $wpdb->posts WHERE ID > 160
- How to show the posts of some category first, and then all other
- Pagination problem after WP_Query with tag filtering
- Custom Loop in Page Admin Causing Other Fields to Fail
- Pagination stops at page 6
- Paginated HTML Sitemap
- How to limit total number of posts in wp query loop?
- How to get posts on a specific date – WP Query
- WP_Query no posts with tax_query
- Get list of terms that have posts in another term
- WP_Query with Metavalue
- My Main Query Modification is Messing up my dynamic main – why?
- Using Ajax to load more posts | Help me change the wording on my button to notify the user
- Adding an array from a query string to a WP meta_query
- WordPress add_rewrite_rule() cannot visit lower url levels
- Get a post from other loop each n-posts in the main loop
- Search for multiple tags?
- WP_Query() and get_posts() can’t handle over a thousand posts?
- Sort by price woocommerce by ID post_meta
- Which is faster wpdb & get_row or wp_query & ge_post_meta?
- Why is WP_Query not displaying expected data?
- Customy WP Query Args are convertet in SQL result
- Filter post query to only show direct children of category
- Highlight current post title on a page
- Why won’t draft listings appear for non-admins?
- My WP_Query didn’t work after upgrading to WordPress 3.2
- meta queries do ‘either/or’ checks
- search serialised meta_value for date value?
- has_excerpt() not working inside wp_query
- Apply query arguments after the nth post
- How to properly use AND / OR in custom search
- Get post and its children with WP_Query
- Get every post with value in meta key
- Using get_posts to get posts based on a checkbox value with Advanced Custom Fields
- Searching by title, content and custom taxonomy
- Storing an array of objects related to each user
- How to get posts by category and by choosing a taxonomy term?
- Paging + WP Query
- Getting the permalink to the latest post from a category
- How to restrict search on a certain page to only return results against custom taxonomies?
- Deleting terms from the WordPress wp terms table
- In a WP_Query can I force the results’ is_singular() to be set to false?
- My combination of ‘post_type’ and ‘tax_query’ not working?
- Query pages created by deleted users
- Get posts that match defined arrays of tags
- WordPress live search and filter
- WordPress Query optimaization for slow query
- WordPress – just refresh blog archive by new query
- how to move a page from one drop down menu to another drop down menu
- WP_Term_Query->get_terms() very slow query for WordPress filter
- How to pass a php variable to js within a template?
- Meta query doesn’t remove placeholder escape before query
- Multiple values in WP_Query : category__and
- Get all wp_users sort by metakey
- How to use wp_query in different column in single loop
- Paginated Post List on Front Page
- Show subscriber id in loop
- modifying the loop multiple times with arguments passed through ajax to wp_query
- WP_Query – show posts where meta value and user_email match
- WP_Query causing links to not work
- Website goes slow down after importing long database
- Pagination for custom query throws 404 errors on last pages [duplicate]
- Order posts by custom column using pre_get_posts
- How to Query Updated Post in WordPress
- wordpress nested loop
- Need help setting up a search form for wordpress [duplicate]
- Including ‘cat’ => $cat breaks meta_query
- problem in query_vars parameters
- Query posts only shows 1
- First post outside of loop, homepage only?
- How to include custom fields in wordpress search
- Extend search query to search meta keys values based on search string
- AJAX multiple search boxes not merging with array merge