简体   繁体   English

如果它是类别页面(在PHP中),我如何告诉WooCommerce不要显示HTML?

[英]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.

相关问题 WooCommerce分类页面如何显示分类缩略图? - How to display category thumbnail on WooCommerce category page? 如何在某个 Woocommerce 类别存档页面中显示已售出/缺货商品,但不在其他页面中显示它们? - How do I show sold/out of stock items in a certain Woocommerce category archive page, but not display them in others? 如何使用PHP显示一个或多个HTML页面? - How do I use PHP to display one html page or another? WordPress-如何在使用category.php的页面中显示自定义帖子类型 - WordPress - How do I display custom post type in page that uses category.php 在Woocommerce类别页面上显示侧边栏 - Display Sidebar On Woocommerce Category Page 如何在Opencart的自定义页面上显示类别模块? - How do i display category module on a custom page in opencart? 如何在woocommerce感谢页面上添加或显示产品价格? - How do I add or display the product price in woocommerce thankyou page? 我如何告诉 Eclipse 将 HTML 文件验证为 PHP? - How do I tell Eclipse to validate HTML files as PHP? 如果有人通过POST或GET来告诉php页面怎么说? - How do I tell for a php page if someone came by POST or GET? Woocommerce - 如何在产品存档中显示父类别页面上的文本? - Woocommerce - How to display the text on the parent category page in the product archive?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM