以下是在我的WooCommerce产品页面上输出的代码片段,其中显示了列中的产品列表。我想将下面的代码包装在一个但不知道要使用哪个命名的钩子。
<li class="post-5908 product type-product status-publish has-post-thumbnail product_cat-lingerie post post-with-thumbnail post-with-thumbnail-large first instock product-type-simple">
<a href="https://www.example.com/product/1260/" class="woocommerce-LoopProduct-link">
<div class="makebottom-wrap">
<img src="https://www.example.com/wp-content/uploads/2017/01/myproduct-300x200.jpg" class="attachment-shop_catalog size-shop_catalog wp-post-image" alt="My sample product" title="My sample product" srcset="https://www.example.com/wp-content/uploads/2017/01/myproduct-300x200.jpg 300w, https://www.example.com/wp-content/uploads/2017/01/myproduct-150x100.jpg 150w, https://www.example.com/wp-content/uploads/2017/01/myproduct-768x512.jpg 768w, https://www.example.com/wp-content/uploads/2017/01/myproduct-1024x683.jpg 1024w, https://www.example.com/wp-content/uploads/2017/01/myproduct-600x400.jpg 600w, https://www.example.com/wp-content/uploads/2017/01/myproduct-272x182.jpg 272w, https://www.example.com/wp-content/uploads/2017/01/myproduct.jpg 1200w" sizes="(max-width: 300px) 100vw, 300px" width="300" height="200">
</div>
<h3>1260</h3>
</a>
</li>
答案 0 :(得分:0)
<li <?php post_class( $classes ); ?>>
<?php
if (has_post_thumbnail( $post->ID )){
echo get_the_post_thumbnail($post->ID, 'shop_catalog');
}else{
echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="65px" height="115px" />';
}
?>
</li>