Hide 'add to cart' button ONLY on woocommerce shop/category pages

前端 未结 7 703
广开言路
广开言路 2021-01-03 15:56

I want to hide the button on my shop pages, but I would like to show it on other posts and pages.

I\'ve found this code to hide the add to cart button on my whole we

7条回答
  •  情歌与酒
    2021-01-03 16:53

    You can use the Woocommerce conditional tags to check: http://docs.woothemes.com/document/conditional-tags/

       add_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 );
    
        function remove_add_to_cart_buttons() {
          if( is_product_category() || is_shop()) { 
            remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
          }
        }
    

提交回复
热议问题