$product = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'product_cip',
'value' => 'some value',
'compare' => '=',
)
),
'fields' => 'ids',
);
$product_post = get_posts($product);
echo count($product_post);
if you have get all products data
$products_array = array();
foreach ($product_post as $v){
$_product = wc_get_product($v);
echo $_product->get_name().',';
$products_array[] = $_product;
}
Related Posts:
- When to use WP_query(), query_posts() and pre_get_posts
- How to get an array of post data from wp_query result?
- How to only display posts whose meta_value field is not empty?
- How to print the excuted sql right after its execution
- WP query taxonomy input differs to output?
- How to add taxonomy filter on the query fly?
- Pagination returns 404 after page 20
- WP_Query min and max values
- post_type is ignored by WP_Query when ‘tag’ argument is included
- How to query posts of standard post format. For real
- Orderby menu_order doesn’t work
- WP_Query by Category Name
- assign 2 $args to one wp_query
- WP_Query OR clause for tax_query and keywords
- Calling a custom excerpt function in a local loop
- Transient pagination not working properly
- query posts in functions.php and update a field
- get_posts() seemingly ignoring post_type
- If orderby parameter using pre_get_posts is the same for multiple posts what fallback does the query use?
- Which filter/action hook gets triggered after a query has been performed?
- Why use JSON API to display recent posts?
- Why query_vars get altered in WP_Query Object?
- pre_get_posts filter meta_query without conflicting existing meta_query
- How would I format a query that depends on post parent taxonomy
- Minimising Database Queries when using Advanced Custom Fields
- List only posts from specific category on category page
- Most popular post for last 7 days
- Get data of all posts of a query before pagination
- WP Pagination on Posts Search Results Page resulting from AJAX WP Query
- How to avoid wp_query returning the same post I’m on in results?
- Custom query for sidebar isn’t returning results
- How to vary post loop results layout and resume?
- Query multiple meta values
- Why isn’t my multiple orderby working?
- WordPress Loop and $post
- How can I create ‘future’ and ‘past’ parameter for restAPI by filtering the CPT custom date field by greater than / less than current datetime?
- WP_Query tax query part of slug
- Query posts without meta preload
- How to implement a new row_count method in WordPress?
- reset to main loop doesnt work
- Applying posts_clauses filter to specific queries only
- Some doubts about how the main query and the custom query works in this custom theme?
- How to do a wp_query with two acf-fields, sorting on one of them
- Using Advanced Custom Field for file upload, how do I load the file url
- Shortcode for latest -not expired- posts
- meta_compare not comparing whole integer
- WP_Query – Object manipulation vs WordPress functions
- Only display post if published in last 24 hours?
- WP_Query with rewind_posts creates duplicate titles
- Transients with dynamic WP_Query
- How to remove the most recent post from $the_query
- WP_Query loop else statement not executing
- Modify Search Query if original Query gave no results
- How to cache wp_query with pagination using transients?
- Problem with WP_query
- Selecting posts with a given meta value for a meta key
- WP_Query by keyword OR post tag
- query_vars empty when using custom url with custom rewrite rule
- Display recent posts on another site
- WP_Query for products always returns empty
- Post archive for certain post format
- Issue with data array format
- Add AJAX “Load more” on custom query block
- Why my query is not “Main_query”?
- Filter sub-category from checkbox form
- Meta Box WP_Query array for showing items with a certain relationship
- Multi-layered WP_Query
- `offset` WP_Query argument dont work via `pre_get_posts`
- Function the_posts_pagination() not compatible with WP_Query arguments
- Facing problem with tax_query results
- How to add a “base” filter for all posts visible to visitors on the site?
- Pagination of custom page with custom fields query
- WP_Query() not filtering posts for category
- wp query search multi terms
- WP_User_Query Orderby Not Working
- Woocommerce featured products query no longer working
- add action for wordpress query at a specific position
- WordPress post_status and meta_query
- How to query wordpress with array of meta_values?
- Updating an intensive wp_query result once daily
- Custom query: post__in parameter causes query to be empty
- Custom WP_query and integrating into theme file
- Custom query return
- WP_Query: Meta_Query with serialized value (or a workaround)
- Query All Attachments and Order by Parent Publish Date
- WP_Query using meta_query with LIKE doesn’t return what it should
- Filter custom post type by custom taxomony
- Query post Pagination Problem
- Having Trouble Running Query From Shortcode Using Tribe’s Events Plugin
- Change ‘post_modify’ with a query
- An archive page without post format (just standard post)
- How to organize a WP_Query’s list of posts by category and display category title?
- Pull Instagram images into an existing loop?
- Query_vars not working for me
- Pagination showing same posts despite changing page
- Query custom post types by meta field in a term from custom taxonomy
- Filtering product search results using tags
- Display Featured image from custom post type category (custom taxonomy) wise
- new WP_Query with order args – no more distinction between categories
- How to make OR condition in WP_Query