【发布时间】:2022-12-01 23:02:11
【问题描述】:
im trying to sort asc by price a specific category for marketing purpouses. the thing is all the shop is configured to show desc, so i used a sn-p but its not working.
add_filter( 'woocommerce_product_query', 'sorting_asc_query', 10, 2 );
function sorting_asc_query( $q ) {
$product_category = array('category-to-be-sorted');
if( is_product_category( $product_category ) ) {
$q->set('orderby', 'post__in');
$q->set('order', 'ASC');
}
}
can you guide me to make it run?
cheers.
【问题讨论】:
-
Please be more specific - Are you wanting to order by product titles ascending alphabetically?
-
oooh sorry, by price. i will edit the question!
标签: woocommerce