You could use the WooCommerce filter woocommerce_shortcode_products_query to change/manipulate the query arguments.
This example comes from the shortcode documentation.
When using the Products shortcode, you can choose to order products by the pre-defined values above. You can also sort products by custom meta fields using the code below (in this example we order product by price):
add_filter( 'woocommerce_shortcode_products_query', 'woocommerce_shortcode_products_orderby' );
function woocommerce_shortcode_products_orderby( $args ) {
$standard_array = array('menu_order','title','date','rand','id');
if( isset( $args['orderby'] ) && !in_array( $args['orderby'], $standard_array ) ) {
$args['meta_key'] = $args['orderby'];
$args['orderby'] = 'meta_value_num';
}
return $args;
}
Related Posts:
- Woocommerce: Complex query in pre_get_posts [closed]
- Woocommerce pre_get_posts query variation meta data not working
- unable to customize query to get filtered products by meta_key
- Getting the gallery images from products in woocommerce?
- add_filter to modify woocommerce_cart_item_name hyperlink
- How to get rid of the hover zoom in WooCommerce single products
- How do I display certain products via their category on a section of a page using PHP?
- Display orders instead of woocommerce my account dashboard for logged in users [closed]
- Detect whether a page is a product subcategory page?
- Programmatically change Payment Methods WooCommerce
- How to show “Previous Category” and “Next Category” in categories archieve template [closed]
- Add product attribute to Woocommerce’s blocks in Gutenberg
- The correct way to override WooCommerce product gallery from a plugin [closed]
- How to update variable product stock status with code
- Woocommerce Product Image and Thumbnails custom function
- Create WooCommerce new order with specific ID
- woocommerce change order statuses count for specific role
- global $post; in WooCommerce
- Woocommerce template single-product.php in theme folder not working
- How can i create a WooCommerce product programatically or using sql query?
- is_user_logged_in() always returns false for woocommerce_login_redirect
- WordPress ‘on behalf of’ email
- Display description on cart page
- Which hook should I use to capture $_POST(‘password’) via profile update and password reset
- display first sale product in shop
- Problems adding in-store product managers
- differentiate hooks and filters on the same page [closed]
- Signup Form that adds customer to MailChimp, redirects to checkout, and fills in form data
- how to pass a woocommerce product name to contact form7 [closed]
- Keep getting Notice: Trying to get property of non-object in …\wp-includes\post.php on line 4153 when generating woocommerce coupon
- How to subscribe free subscription on user registration in woocommerce subscription plugin?
- WooCommerce Product URL re-writing
- Automatically running Scheduled Actions
- Hook to use when customer placing order
- Woocommerce Rest Api Categories problem [closed]
- Woocommerce cart page – Add “Free” to the shipping label when shipping is 0
- Change product in cart when billing country is changed
- Calculate tax on sales price excluding discount [closed]
- One file for all virtual, downloadable product variations [closed]
- How to override the title tag for woocommerce endpoints?
- WooCommerce – Global $product is returning value null
- How to re-arrange this hooked content?
- Pre filter woocommerce products to remove a certain category of products
- WooCommerce Stripe Plugin not showing up in settings [closed]
- Remove “?add-to-cart=product-id” from Add to Cart URL when on the Cart page
- How to show total amount on woocommerce?
- Woocommerce, finding the ordinal number of a purchase for a certain product
- WooCommerce order refund get qty refunded
- Disable Order Review Page when the id product
- Set both meta_query and tax_query using wp_query->set
- Is there a preset CSS class when shopping cart isn’t empty?
- WooCommerce Simple Product Options List
- Add custom body tag if product is out of stock
- Protecting WooCommerce Customizations with Update
- Setting WooCommerce SKU programmatically [closed]
- How to edit mobile view of my wordpress website without affecting the desktop view? [closed]
- WooCommerce: How to insert filtered attribute(s) in page title of archive?
- Multiple Pricing [closed]
- WOOF product filter prevent from loading on wordpress search result page
- WooCommerce login redirect based on cart
- Adding product on sale into specific category after creation
- How to select the first product variant as a default?
- WooCommerce – dynamically loading checkout page using ajax not showing payment methods for guest
- call_user_func_array() expects parameter 1 to be a valid callback, class ‘WC_Rapyd’ does not have a method ‘install’
- Conditional for product attribute page
- Setting Page Visibility for WooCommerce Default Page Doesn’t Work
- Deleted products from woocommerce are still in the database
- Remove cart functionality from WooCommerce so it doesn’t remember the products [closed]
- Apply CSS to certain product thumbnails only
- Pass values to ajax
- Send Email to Custom Field in Custom Post Type when order is Completed
- Fragments to Update Cart Counter not working on homepage – Woocommerce
- WooCommerce Review Author Hook on Review Submission
- Order Woocommerce Products by On Sale and Alphabetically
- How to track product price changes?
- Woocommerce Flexslider touch functionality on desktop not working
- Filter orders in Admin area based on logged in user
- Exclude Specific Product Category for showing up in its parent category page
- Customer Email Address
- How to echo woocomerce attributes values in dropdown box
- Add new page in WooCommerce My Account page
- Uninitialised Parameters using woocommerce_checkout_update_order_meta hook
- Woocommerce customer role doesn’t change if user is already a subscriber [closed]
- Tags pages for different Custom Post Types and WooCommerce Products sharing Post Tags
- get_posts only getting most recent product
- How to only show featured products in wooCommerce using function.php function
- How to insert link, with lightbox, that opens specific page content only
- How to get the WooCommercer product variation image
- how add css class to product boxes li, for img, add cart button, decs, price… [closed]
- Vendor Listing by Location
- How can I hide the entire “Shipping Details” block on the admin side of Woocommerce? [closed]
- Decrease stock quantity when a variation is sold using Woocommerce
- WooCommerce show decimals in totals [closed]
- Woocommerce Mandatory Field on Shipping Details [closed]
- Create a shortcode to show product tag name on tag archive
- How to access Woo Commerce products from within custom theme? [closed]
- Can I remove WooCommerce specific product categories from shop managers?
- Fetch products with filter by similar categories at same time
- Disable Woocommerce Block Editor
- Conflict between Woocommerce Booking + Woocommerce Product Options [closed]