Hello,
Thank you so much for your reply. I tried that option, however, all the sold-out products on my Archive page disappeared.
I am adding this code to my functions.php for the Archive page
add_shortcode( 'out_of_stock_products', 'bbloomer_out_of_stock_products_shortcode' );
function bbloomer_out_of_stock_products_shortcode() {
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'column' => 3,
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => '_stock',
'value' => 1,
'compare' => '<'
)
),
'fields' => 'ids',
);
$product_ids = get_posts( $args );
$product_ids = implode( ",", $product_ids );
return do_shortcode("[products ids='$product_ids']");
}
And [out_of_stock_products] to display all sold-out products.
Do you happen to know other way to display sold out products and hide them from category pages?Thank you so much.