Php Wordpress/Woocommerce通过ID获取单个产品照片
我正在尝试为wordpress/WooCommerce创建自定义快捷码,这样我就可以只选择一个产品的图片或价格,因为我想设计产品页面的样式,但我不能使用他们自己制作的快捷码 我在谷歌上看了很多,在预览中尝试了多种代码,但没有成功:( 也许有人能帮我解决这个问题 这就是我现在所拥有的,而且到目前为止,它仍然有效Php Wordpress/Woocommerce通过ID获取单个产品照片,php,wordpress,shortcode,Php,Wordpress,Shortcode,我正在尝试为wordpress/WooCommerce创建自定义快捷码,这样我就可以只选择一个产品的图片或价格,因为我想设计产品页面的样式,但我不能使用他们自己制作的快捷码 我在谷歌上看了很多,在预览中尝试了多种代码,但没有成功:( 也许有人能帮我解决这个问题 这就是我现在所拥有的,而且到目前为止,它仍然有效 //Select just one img from a WooCommerce product. function singleProduct_img( $atts ) { $
//Select just one img from a WooCommerce product.
function singleProduct_img( $atts ) {
$a = shortcode_atts( array(
'product_id' => '',
), $atts );
return $a['product_id'];
}
add_shortcode( 'singleProduct_img', 'singleProduct_img' );
我使用的快捷码是:[singleProduct\u img product\u id=“233”]
,输出是“233”
现在我希望我可以返回id=“233”的产品图像
顺便说一句:
Woo=版本2.6.8
WP=版本4.6.1–nl_nl
任何帮助都将受到感谢
谢谢使用:
该死的……我不认为解决办法这么简单:(产品的美元价格也有这样的问题吗??:oLook这里:
return get_the_post_thumbnail( $a['product_id'], 'medium' );