meta_query
format and orderby
format should be as follows:
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page'=> 10,
'orderby' => 'total_sales',
'order' => 'DESC',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => '_featured',
'value' => 'yes',
'compare' => '='
),
array(
'key' => 'total_sales',
'value' => '10',
'compare' => '>='
)
)
);
$query = new WP_Query( $args );
Instead of meta_key
and meta_value
use key
and value
with compare
as mentioned. You can see related documentation of WP_Meta_Query which also works with WP_Query.
Related Posts:
- WooCommerce conditional meta query
- WordPress query through Products variation stock [closed]
- Filter WooCommerce Orders query with user meta data
- WP_Query with meta_query for children
- Tax Query for custom Taxonomy field
- Filtering variable WooCommerce products by stock level using meta_query
- Set both meta_query and tax_query using wp_query->set
- Need to check if user has completed a woo commerce payment
- Sort products by Sale price and stock status
- how to get woocommerce product attribute slug
- How to display product price of the product in loop
- How to build a plugin that supports authenticated POST requests to the REST API from external servers?
- How do I add a text input field for customers to leave a note on a single WooCommerce product page?
- Get Woocommerce Subscription Product
- WooCommerce pages accessible to logged in members only
- Auto update cart after quantity change
- paypal not showing on woocommerce payments
- Target WooCommerce Product Gallery Image (rather than Featured Image) for og:image
- Save and display selected product option and cost as cart item data in WooCommerce
- How to remove product base from WooCommerce product permalinks
- woocommerce image product add a class and data-src attributes
- Woo create order only after payment done
- Change Category Widget Dropdown List Select Name
- Remove the link from the thumbnail and product title on woocommerce
- How to upload Woocommerce product images via API? [closed]
- Custom Admin Email Subject for Woocommerce (3.8.0) Orders
- Woocommerce custom endpoints
- How to override Woocommerce functionality in Reports section?
- how can use woocommerce add to cart popup?
- Do I need a different product type for WooCommerce [closed]
- How to change product thumbnail size in storefront theme
- Override static method in WC_Shortcodes class (shortcode) [closed]
- Show add to cart button and quantity field when no price is entered [closed]
- How to get woocommerce product collection in template file
- Results not being printed
- Remove ‘product’ & ‘product-cateogory’ from url – woocommerce [closed]
- Why is my WordPress login credentials missing, but work with WooCommerce?
- Update Customer JWT Woocommerce
- Is there a hook in woocommerce for when a payment fails to display a custom error message?
- How to show notice alert only on product dashboard page?
- Retrieving Tag Name in Template Part from Filtered URL
- ajax request in wordpress
- Woocommerce product rewrite rules not working
- How to display a table below each product in product list/loop
- separate functions for home VS other pages
- WooCommerce apply shipping rates based on price
- Extra items added to cart on refresh, woocommerce
- How disable some product features on woocomerce?
- WooCommerce – Split Multiple Items into Individual Line Items
- Change “Select Options” label in button to “Buy Now!” in store page
- Woocommerce purchase date [closed]
- How to add a special Woocommerce “buy now” button?
- Woocommerce: Any way to list all products *without* a specific attribute?
- Filter by Price filter button not working
- porto theme pagination on woocommerce not working
- Adding preference buttons to main nav that persist via user sessions. (Woocommerce)
- Woocommerce custom log in and register
- Urgent Validate Save-Post Hooks on Woo-commerce product entry form!
- Is doing a database query in Woocommerce efficient to only display posts from a certain category?
- Call product search from custom hook
- CallBack URL for payment gateway redirecting to homepage instead of executing callback function
- Display when items are in Woocommerce cart but hide when empty
- Printing product variation return array to string conversion error
- woocommerce deposit Form with AJAX and shortcode won’t update but add to previous output
- How to get cookie value?
- Woocommerce Disabling Auto Restocking for Cancelled Orders
- Custom pagination permalink structure Product page
- Woocommerce change the price of products in the database
- Woocommerce modifying the html on the checkout page?
- Pseudo class :before don’t working in a specific button
- How to speed up “My Account > Orders Page” on Site with More than 200,000 orders?
- Editing product categories suddenly crashes website and goes back to wordpress installation
- “error_message”: “Sorry, you cannot list resources.” using WooCommerce API
- WooCommerce product details page category display
- Woocommerce – Default product image by user role
- WooCommerce product id as permalink
- Merge “description” and “additional informations” product tab
- I need to refresh the checkout page if someone changes the zip code
- WooCommerce does not translate every string
- Woocommerce add a text field if specific option is selected
- Add suffix to price html does not work
- Get user active posts randomly
- SyntaxError: unterminated string literal – if WordPress Debug in wp-config is set to true
- How Fragile Is DB if I Upload Completely Updated Files
- Broken 302 redirection for product subcategory (Woocommerce, Apache)
- Website Tablet Check Out Field Issue
- WooCommerce order created via REST – sending the date_created along
- How to allow registration only from a certain location?
- Add confirmation popup on place order button
- Get Third Level Categories WooCommerce
- Change wp-login.php? Problem with .htaccess password protection and multi user shop
- Change WooCommerce Checkout Button – Reverts to normal
- Show pop up message for specific categoryies
- How to remove content from hacked pages? [closed]
- Disable WooCommerce Address State Dropdown
- How to show detailed order history on woocommerce product page [closed]
- registration_errors not working
- Detect Product Type with code
- Verify if woocommerce supports this design [closed]
- Hook for Woocommerce checkout fields