我想在woocommerce中显示仅图像产品。
我的提取查询如下
$args = array( 'post_type' => 'product', 'stock' => 1, 'posts_per_page' => 9, 'orderby' =>'date','orderby' => 'rand' );
$loop = new WP_Query( $args );
我怎样才能只获得图像产品?
您是否正在寻找这样的东西?
<?php
$args = array( 'post_type' => 'product', 'stock' => 1, 'posts_per_page' => 9, 'orderby' =>'date','orderby' => 'rand' );
$loop = new WP_Query( $args );
while ($loop->have_posts()) : $loop->the_post();
echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog');
endwhile;
?>
更新
$args = array(
'post_type' => 'product',
'stock' => 1,
'posts_per_page' => 9,
'orderby' =>'date',
'orderby' => 'rand',
'meta_query'=>array(
array(
'key'=>'_thumbnail_id',
'compare' => 'EXISTS'
)
)
);
更改arg以获取具有特征图像的产品。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句