您好我正在使用以下代码对woocommerce产品标题进行下拉
<select Name='choose' id="chooseme">
<?php
$args = array( 'post_type' => array('product') ,'posts_per_page' => 100);
$loop = new WP_Query( $args );
;
while ( $loop->have_posts() ) :
$loop->the_post();
echo '<option selected value="'.the_title().'</option>';
endwhile;
?>
</select>
现在我想从此查询中获取产品图片。是否可以从此代码中获取图像,或者还有其他解决方案吗?
答案 0 :(得分:0)
您只需使用get_the_post_thumbnail()
:
echo get_the_post_thumbnail($loop->post->ID, 'yourTable');
while()
示例:强>
while ($loop->have_posts()) : $loop->the_post();
echo get_the_post_thumbnail($loop->post->ID, 'yourTable');
endwhile;