WooCommerce [products] shortcode order by product attribute
-
I’m using the default WooCommerce [products] shortcode as indicated in the example here https://docs.woocommerce.com/document/woocommerce-shortcodes/#section-7 and the default
orderby
values are only:– date – The date the product was published.
– id – The post ID of the
product.
– menu_order – The Menu Order, if set (lower numbers display
first).
– popularity – The number of purchases.
– rand – Randomly order
the products on page load (may not work with sites that use caching,
as it could save a specific order).
– rating – The average product
rating.
– title – The product title. This is the default orderby mode.But I need it to be ordered by a custom product attribute present on all of my products named
custom_index
. Is it possible to filter the [product] shortcode to achieve a customorderby
from a product attribute?Already tried
[products orderby="custom_index" order="ASC"]
and hooking intowoocommerce_product_query
, but it seems none works.
- The topic ‘WooCommerce [products] shortcode order by product attribute’ is closed to new replies.