【问题标题】:Displaying main product image from Woocommerce with a custom plugin使用自定义插件显示来自 Woocommerce 的主要产品图片
【发布时间】:2021-09-25 18:11:10
【问题描述】:

您好,我正在尝试创建一个自定义插件,该插件将显示来自 Woocommerce 插件的主要产品图像。我想使用简码。我该怎么做呢?这就是我所拥有的,但它没有用。我也发现了不同的建议。我将在下面分享所有内容

add_shortcode( 'product_image', 'bbloomer_product_image_shortcode' );

    function bbloomer_product_reviews_shortcode() {    
       return woocommerce_get_product_thumbnail();
    }

<?php
$gallery_shortcode = '[gallery id="' .intval($post->$post_parent).'"]';
print apply_filters('the_content', $gallery_shortcode);
?>

这些是我之前发现/建议给我的

【问题讨论】:

  • 您要在产品页面上使用该短代码吗?

标签: php wordpress woocommerce plugins


【解决方案1】:

试试这个:

$featured_image = wp_get_attachment_url( get_post_thumbnail_id($product_id)); 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-10
    • 1970-01-01
    • 2019-06-15
    • 2021-09-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多