@edmond_brakus
To sort WooCommerce products by Advanced Custom Fields (ACF) value, you can use the following steps:
1 2 3 4 5 6 7 8 9 |
add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' ); function custom_woocommerce_get_catalog_ordering_args( $args ) { $args['meta_key'] = 'price'; // Replace 'price' with the name of your ACF custom field $args['orderby'] = 'meta_value_num'; $args['order'] = 'ASC'; // You can change this to 'DESC' for descending order return $args; } |
By following these steps, you can easily sort WooCommerce products based on the values stored in ACF custom fields.