WooCommerce - 隐藏产品图片(如果没有)

时间:2015-08-11 09:39:44

标签: php wordpress twitter-bootstrap woocommerce

我正在开发一个使用WooCommerce的Bootstrap主题。我正在尝试隐藏产品图片/图库所在的col-md-1,如果没有,请将我的产品图片列从col-md-5生成到col-md-6

页面设计包含3列:

  1. col-md-5 - 产品图片
  2. col-md-1 - 产品图片/图库
  3. col-md-6 - 产品信息
  4. Here you can see where the product has more images in the col-md-1

    Here you see it without product images

1 个答案:

答案 0 :(得分:0)

这是一个可以帮助您的代码。

jQuery( document ).ready(function(){
if(jQuery('.col-md-1').children().length===0){
jQuery('.col-md-1').css('display','none');
jQuery('.col-md-5').toggleClass('col-md-6');
jQuery('.col-md-5').removeClass('col-md-5');
}
});

首先在浏览器中加载页面,然后将以下代码粘贴到控制台中以查看效果。

如果您想要此代码,则添加相同代码以仅在单个产品页面上有条件地加载它。

相关问题