I want to sort products for specific book category page woocommerce but i am unable to do that
below is the code i have applied but not worked for me
/*
add_filter('woocommerce_default_catalog_orderby','custom_catalog_ordering_args_func',220, 1);
function custom_catalog_ordering_args_func($sortby)
{
$product_category = 'book'; // <== HERE define product category slug
if (! is_product_category($product_category)) {
return;
}else{
return 'date';
}
}
*/
2
Answers
Use this code
You can use
woocommerce_default_catalog_orderby
action hook. check the below code.