首頁  >  問答  >  主體

從 WooCommerce 商店主題的主頁中刪除產品類別區塊

<p>我正在嘗試刪除 WooCommerce Storefront 主題主頁中顯示的預設產品類別部分區塊。 </p> <p>我嘗試透過在functions.php中使用幾個鉤子來刪除該區塊,例如:</p> <pre class="brush:php;toolbar:false;">function remove_storefront_category() { remove_action( 'woocommerce_after_shop_loop', 'storefront_sorting_wrapper', 9); remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10); remove_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20); remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30); remove_action( 'woocommerce_after_shop_loop', 'storefront_sorting_wrapper_close', 31); remove_action( 'woocommerce_after_shop_loop', 'woocommerce_reset_loop', 999); } add_action( 'woocommerce_after_shop_loop', 'remove_storefront_category' );</pre> <p>但無論我嘗試什麼,此產品類別部分區塊都不會消失。 </p> <p>我搜尋了很多,只找到了有關隱藏特定類別的信息,但我想完全隱藏它。 </p>
P粉908138620P粉908138620385 天前548

全部回覆(1)我來回復

  • P粉322106755

    P粉3221067552023-09-04 11:21:56

    要從店面主題主頁刪除產品類別部分,您可以使用以下簡單的程式碼片段:

    add_action( 'init', 'remove_storefront_home_product_categories', 10 );
    function remove_storefront_home_product_categories(){
        // Unhook storefront_product_categories() function from 'homepage' action hook
        remove_action( 'homepage', 'storefront_product_categories', 20 );
    }

    程式碼位於活動子主題(或活動主題)的functions.php 檔案中。經過測試並有效。

    回覆
    0
  • 取消回覆