我想在数组中获取wooccommerce缩略图src-url



我想在以下图像属性中获取缩略图url

$product = wc_get_product( $post->ID ); //do this instead
$end_point   = 'https://api.webpushr.com/v1/notification/send/sid';
//do a wp_remote_post instead of cURL
$body = array(
'title'      => $product->get_name(),
'message'    => 'check out now',
'target_url' => $product->get_permalink(),
'image'      => $product->get_image($attr = array( 'src'=>get_the_post_thumbnail_url())), // Here I want to get Image thumbnail url. But it is not working
'sid'        => '113858026',
);

你可以这样写:

'image' => wp_get_attachment_image_url( $product->get_image_id(), 'thumbnail' )

其中使用$product->get_image_id()获取图像id,然后使用wp_get_attachment_image_url获取url。

最新更新