I have the following snippet which adds post thumbnails to products on archive page if matches a given product category, which will output the image but echos the the post id as well. How do I suppress to not show post id?
add_action( 'woocommerce_after_shop_loop_item_title', function () {
if(is_product_category('t-shirts')) {
$thumb = get_the_post_thumbnail( the_ID());
if(is_string($thumb) ) {
echo '<div class="imagewrapper">' . $thumb;
}
}
}, 9 );
add_action( 'woocommerce_after_shop_loop_item_title', function () {
if(is_product_category('t-shirts')) {
$thumb = get_the_post_thumbnail( the_ID());
if(is_string($thumb) ) {
echo '</div>';
}
}
}, 11 );
I have the following snippet which adds post thumbnails to products on archive page if matches a given product category, which will output the image but echos the the post id as well. How do I suppress to not show post id?
add_action( 'woocommerce_after_shop_loop_item_title', function () {
if(is_product_category('t-shirts')) {
$thumb = get_the_post_thumbnail( the_ID());
if(is_string($thumb) ) {
echo '<div class="imagewrapper">' . $thumb;
}
}
}, 9 );
add_action( 'woocommerce_after_shop_loop_item_title', function () {
if(is_product_category('t-shirts')) {
$thumb = get_the_post_thumbnail( the_ID());
if(is_string($thumb) ) {
echo '</div>';
}
}
}, 11 );
Share
Improve this question
asked Jun 17, 2019 at 14:05
fefefefe
8943 gold badges14 silver badges34 bronze badges
1 Answer
Reset to default 2I believe because:
the_ID() : Display the ID of the current item in the WordPress Loop.
and
get_the_ID() : Retrieve the ID of the current item in the WordPress Loop.
So the_ID()
displays the post ID.
Try to use get_the_ID()
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745393644a4625779.html
评论列表(0条)