-
-
Save felipeelia/906a382ec174b8113fe656897a2f0e95 to your computer and use it in GitHub Desktop.
WooCommerce - Change default catalog sort order to stock status and date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This code should be added to functions.php of your theme | |
**/ | |
function my_woocommerce_catalog_orderby( $args ) { | |
$args['meta_key'] = '_stock_status'; | |
$args['orderby'] = array( 'meta_value' => 'ASC', 'date' => 'DESC' ); | |
return $args; | |
} | |
add_filter( 'woocommerce_get_catalog_ordering_args', 'my_woocommerce_catalog_orderby' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
works in 2021