[英]How do I tell WooCommerce NOT to display HTML if it is a category page (in PHP)?
I am trying to add some HTML code into the WordPress main shop page, but not have it appear on the category pages. 我正在尝试将一些HTML代码添加到WordPress主商店页面中,但是没有将其显示在类别页面上。 I am using the code below, but the HTML is still showing up on the category pages.
我正在使用下面的代码,但是HTML仍显示在类别页面上。 I also tried using a category array with the category names, but it wasn't working.
我也尝试过使用带有类别名称的类别数组,但是没有用。 Is there a specific format for the category names (like no capitals or &'s)?
类别名称是否有特定格式(例如不使用大写字母或&)? What am I missing?
我想念什么?
Thank you ahead of time!! 提前谢谢你!!
<?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 ?>
Your PHP condition is missing some parts, try this: 您的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.