【问题标题】:Get Woocommerce Cart Product Image Url So I can use it as background image instead获取 Woocommerce 购物车产品图片网址,以便我可以将其用作背景图片
【发布时间】:2017-06-07 15:38:39
【问题描述】:

在 cart.php 中我们有:

<td class="product-thumbnail" style='background:url(<?php ?>)'>
                            <?php
                                $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );

                                if ( ! $product_permalink ) {
                                    echo $thumbnail;
                                } else {
                                    printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail );
                                }
                            ?>
                        </td>

有没有办法从中获取 url,以便我可以在 td 元素上使用背景图像而不是内部的图像标签?

【问题讨论】:

    标签: php wordpress woocommerce cart


    【解决方案1】:

    能够使用它来工作

    <?php echo get_the_post_thumbnail_url($product_id);?>
    

    如果出于某种原因,这不是解决此问题的最佳方法,请分享。

    谢谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-08
      • 2015-03-31
      • 2017-04-27
      • 2015-11-15
      • 1970-01-01
      • 2021-03-31
      相关资源
      最近更新 更多