Created
June 1, 2021 19:10
-
-
Save manuelhudec/24ce305b5470bdb884741089bd680c7b to your computer and use it in GitHub Desktop.
WooCommerce - Show out of stock products in archives last
This file contains hidden or 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
add_action( 'woocommerce_product_query', 'out_of_stock_last', 999 ); | |
function out_of_stock_last( $query ) { | |
if ( is_admin() ) return; | |
$query->set( 'meta_key', '_stock_status' ); | |
$query->set( 'orderby', array( 'meta_value' => 'ASC' ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment