隐藏缺货商品woocommerce查询

Hide out of stock products woocommerce query

绑定以隐藏查询中的缺货产品

<?php
                $args = array( 
                        'post_type' => 'product', 
                        'posts_per_page' => 16, 
                        'product_cat' => 'crisps', 
                        'orderby' => 'rand',
                        'meta_query' => array (
                            'key' => '_stock_status',
                            'value' => 'instock'
                        )
                    );
                $loop = new WP_Query( $args );
                if ( $loop->have_posts() ) {
                    while ( $loop->have_posts() ) : $loop->the_post();
                        wc_get_template_part( 'content', 'product' );
                    endwhile;
                } else {
                    echo __( 'No products found' );
                }
                wp_reset_postdata();
                ?>

但是缺货的商品还在显示

任何帮助

尝试

'meta_query' => array (
        array(
            'key' => '_stock_status',
            'value' => 'instock'
        ),
    )