[英]How do I tell WooCommerce NOT to display HTML if it is a category page (in PHP)?
我正在尝试将一些HTML代码添加到WordPress主商店页面中,但是没有将其显示在类别页面上。 我正在使用下面的代码,但是HTML仍显示在类别页面上。 我也尝试过使用带有类别名称的类别数组,但是没有用。 类别名称是否有特定格式(例如不使用大写字母或&)? 我想念什么?
提前谢谢你!!
<?php if (!is_category( ) ) ?>
<div class="shop_giftcard_box">
<a href="/product/gift-card/"><div class="shop_giftcard_image"><img src="http://example.com/wp-content/uploads/2017/03/gift_card_3.png"></div></a>
<div class="shop_giftcard_subheading"><h3><a href="/product/gift-card/">Gift Card</a></h3></div>
</div>
<?php ?>
您的PHP条件缺少某些部分,请尝试以下操作:
<?php if ( !is_product_category() ) : ?>
<div class="shop_giftcard_box">
<a href="/product/gift-card/"><div class="shop_giftcard_image"><img src="http://example.com/wp-content/uploads/2017/03/gift_card_3.png"></div></a>
<div class="shop_giftcard_subheading"><h3><a href="/product/gift-card/">Gift Card</a></h3></div>
</div>
<?php endif; ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.