This topic has 4 replies, 3 voices, and was last updated 5 months, 2 weeks ago ago by Andrew Mitchell
Good morning, I managed to sort the products based on the date entered in a custom field and it works on this page:
https://staging.sviluppomanageriale.it/catalogo-corsi/
However, I can’t get it to work in list mode, like on this page:
https://staging.sviluppomanageriale.it/lista-corsi-test/
This is the script I placed in functions.php. Can you help me make it work in list mode as well?
add_filter('woocommerce_get_catalog_ordering_args', 'woocommerce_catalog_orderby');
function woocommerce_catalog_orderby( $args ) {
$args['order'] = 'ASC';
$args['meta_key'] = 'data_corso'; // ACF
$args['orderby'] = 'meta_value';
return $args;
}
Thank you.
Graz
Hi @Graziano,
Please also take a look at this file: /wp-content/plugins/et-core-plugin/app/controllers/elementor/general/product-list.php on the line 3184
return new \WP_Query( apply_filters( 'woocommerce_products_widget_query_args', $query_args ) );
So you have to hook to this filter also, the full code maybe like this:
add_filter('woocommerce_get_catalog_ordering_args', 'woocommerce_catalog_orderby');
add_filter('woocommerce_products_widget_query_args', 'woocommerce_catalog_orderby');
function woocommerce_catalog_orderby( $args ) {
$args['order'] = 'ASC';
$args['meta_key'] = 'data_corso'; // ACF
$args['orderby'] = 'meta_value';
return $args;
}
Please note that the customization codes are out of scope our support standard. Should you require any further assistance or have additional questions, please do not hesitate to contact us.
If you require personal customization services, we invite you to submit a request through our customization panel at: https://www.8theme.com/account/#etheme_customization_panel , and continue conversations with the technicians team directly.
Best Regards,
The 8Theme Team
It works!
Thanks! I really appreciate!
Have a nice day
Graz
Dear Graziano,
Choosing our theme reflects your commitment to quality, and for that, we’re genuinely grateful. As we constantly strive to elevate your experience, your feedback is an invaluable gift. Could you kindly take a moment to rate our product with 5 stars on ThemeForest?
Click here to share your insights: https://themeforest.net/downloads
Your support fuels our journey, and we appreciate it more than words can express.
Best Regards,
The 8Theme Team
The issue related to '‘Order product by AdvancedCustomField value’' has been successfully resolved, and the topic is now closed for further responses