简体   繁体   中英

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. I am using the code below, but the HTML is still showing up on the category pages. 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 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; ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM