Adding add to cart button to product category pages
-
Hi there,
I’m wondering if anyone could help me with a small modification to Woocommerce. I’m hoping to display an Add to Basket button with products when seen only in product category pages.
So far I have tried adding:
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 20 );
to the functions.php file. This does add the button, see this page, BUT it also shows it on the main shop page, see this page.
To target product category pages only, I’ve tried:
if ( is_product_category() ){ add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 20 ); }
but this stopped the button showing up on ALL pages.
I’m obviously doing something a bit wrong, but please could you point me in the right direction?
Many thanks in advance,
Mark
Viewing 14 replies - 1 through 14 (of 14 total)
Viewing 14 replies - 1 through 14 (of 14 total)
- The topic ‘Adding add to cart button to product category pages’ is closed to new replies.