This topic has 2 replies, 2 voices, and was last updated 1 months, 3 weeks ago ago by Luca Rossi
Hi,
How can I have the list of Woocommerce products with the sorting option “Date Modified”?
Also, I wanted to add the date of Modification as well (Meta)
Refer to the attached image.
Hi @Vijith,
1. Please add the following code under functions.php file locates in your child theme:
add_filter('woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args');
function custom_woocommerce_get_catalog_ordering_args($args) {
if (isset($_GET['orderby']) && 'date_modified' == $_GET['orderby']) {
$args['orderby'] = 'modified';
$args['order'] = 'desc';
}
return $args;
}
add_filter('woocommerce_default_catalog_orderby_options', 'custom_woocommerce_add_new_orderby');
add_filter('woocommerce_catalog_orderby', 'custom_woocommerce_add_new_orderby');
function custom_woocommerce_add_new_orderby($sortby) {
$sortby['date_modified'] = 'Date Modified';
return $sortby;
}
2. Please provide the website URL reference to this screenshot: https://userimg.8theme.com/storage/2024/09/17/34585-Screenshot%202024-09-17%20122517.png.
Thank you!
You must be logged in to reply to this topic.Log in/Sign up