我只想在woocommerce_get_product_thumbnail中插入一个包装器,我可以看到我的包装器出现但是如果没有图像,它没有后退图像.
如何输出默认的woocommerce缩略图?
这是我不完整的代码:
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
if ( ! function_exists( 'woocommerce_template_loop_product_thumbnail' ) ) {
function woocommerce_template_loop_product_thumbnail() {
echo woocommerce_get_product_thumbnail();
}
}
if ( ! function_exists( 'woocommerce_get_product_thumbnail' ) ) {
function woocommerce_get_product_thumbnail( $size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0 ) {
global $post, $woocommerce;
$output = '<div class="col-lg-4">';
if ( has_post_thumbnail() ) {
$output .= get_the_post_thumbnail( $post->ID, $size );
} else {
how to show the default woocommerce thumb
}
$output .= '</div>';
return …
Run Code Online (Sandbox Code Playgroud) 我正在尝试显示我在自定义帖子类型中创建的类别中的帖子。
这是我当前的循环代码,
我想在公告帖子类型中显示奖项类别的帖子
<?php $loop = new WP_Query( array( 'posts_per_page' => 99,'post_type' => 'annoucements','orderby' => 'date','order' => 'ASC','ignore_sticky_posts' => 1, 'paged' => $paged ) ); if ( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php the_title()?>
<?php endwhile; endif; wp_reset_postdata();?>
Run Code Online (Sandbox Code Playgroud)