我尝试了许多方法和解决方案,但我无法使产品图像可点击。代码如下:
if ( has_post_thumbnail() ) {
$images .= get_the_post_thumbnail( $post->ID, \'shop_catalog\' );
}
如果我让代码看起来像这样,它不会显示图像:
return \'<a href="\' . get_permalink( $post->ID ) . \'">\' . get_the_post_thumbnail( $post->ID, \'shop_catalog\' ) . \'</a>\';
最合适的回答,由SO网友:sakarya 整理而成
try this..
$images .= \'<a href="\' . get_permalink( $post->ID ) . \'">\';
if ( has_post_thumbnail() ) {
$images .= get_the_post_thumbnail( $post->ID, \'shop_catalog\' );
}
$images .= \'</a>\';