【问题标题】:Wordpress / Woocommerce - Hide Gallery Picture if there is none or in a specific categoryWordpress / Woocommerce - 如果没有或在特定类别中,则隐藏图库图片
【发布时间】:2017-12-10 14:47:57
【问题描述】:

我有一家使用 Woocommerce 的 Wordpress 制作的商店,我想隐藏产品的图库图片,或者将图库图片隐藏在我制作的特定类别中。

希望能帮到你

【问题讨论】:

    标签: wordpress image woocommerce gallery shop


    【解决方案1】:

    如果您不想显示任何图像,下面的代码将显示默认图像而不是实际产品图像,然后只需从下面的过滤器回调方法返回 false, 同样在这种方法中,您可以检查产品类别,并且只能删除特定产品类别的图像

    add_filter('woocommerce_single_product_image_thumbnail_html','show_default_image');
    
    function show_default_image(){
    $html  = '<div class="woocommerce-product-gallery__image--placeholder">';
                $html .= sprintf( '<img src="%s" alt="%s" class="wp-post-image" />', esc_url( wc_placeholder_img_src() ), esc_html__( 'Awaiting product image', 'woocommerce' ) );
                $html .= '</div>';
    return $html
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-28
      • 2020-04-07
      • 2018-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-24
      相关资源
      最近更新 更多