簡體   English   中英

如果它是類別頁面(在PHP中),我如何告訴WooCommerce不要顯示HTML?

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

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM