如果在woocommerce中找到图像并过滤产品,则获取产品

时间:2016-01-04 18:15:13

标签: image if-statement woocommerce fetch product

我遇到了一个大问题,我在我的网站上使用了这段代码 - fetch products if image is found in woocommerce?

<?php 
   $args = array( 
                'post_type' => 'product', 
                'stock' => 1, 
                'posts_per_page' => 9, 
                'orderby' =>'date',
                'orderby' => 'rand', 
                'meta_query'=>array(
                    array(
                        'key'=>'_thumbnail_id', 
                        'compare' => 'EXISTS'
                    )
                )
            );
    $loop = new WP_Query( $args );
    while ($loop->have_posts()) : $loop->the_post();
        echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog');
    endwhile;
?>

但我无法过滤产品,我是否必须按顺序放置一些变量? 我不能把它按顺序排列

0 个答案:

没有答案