I use WooCommerce and would like to show the products "out of stock" last on the archive page in the query. How do I get to do that? We are currently making the first show of the newest product with this code
add_action( 'pre_get_posts', 'mik_exclude_category' );
function mik_exclude_category( $query ) {
if ( $query->is_main_query() ) {
$query->set( 'orderby', 'date' );
$query->set( 'order', 'DESC' );
}
}
We need to do both. newest products first, "out of stock" products last no matter how new they are.