thumb

Sometimes, WooCommerce store owners do not want to display a links to the product details pages on the product listing page on their website. This can be helpful if you are going to use Quick View instead, or your products don’t require much description, or you link to product pages elsewhere. This will leave only the “Add to cart” button available, so customers will not be able to get to the product details page, but they will still be able to purchase the product. In this article, I will show you how to remove the links to the product details pages from the product listing page of a WooCommerce store.

Solution

A better and safer way to solve this is by removing the open and close link actions. This will prevent side effects such as the “Add to cart” button disappearing.

To do this, add the following PHP snippet to functions.php file of your child theme or use the My Custom Functions plugin for better and easy management of all your PHP snippets.

// Remove links to the product details pages from the product listing page of a WooCommerce store
remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 );

If this code doesn’t work with your theme, the hooks and/or priorities may be different. Look at wp_content/themes/your-theme-name/woocommerce/content-product.php to see how your theme has done this.

If you want to target only a specific category then add the following PHP snippet to functions.php file of your child theme or use the My Custom Functions plugin for better and easy management of all your PHP snippets.

// Remove links to the product details pages from the product listing page of a WooCommerce store (only a specific category)
if ( is_product() && is_product_category( array('category-slug') ) ) {
    remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 );
}

If this code doesn’t work with your theme, the hooks and/or priorities may be different. Look at wp_content/themes/your-theme-name/woocommerce/content-product.php to see how your theme has done this.

Conclusion

That’s it, you’re done. Now the links to the product details pages removed. So simple isn’t it?

I hope this article has helped you learn how to remove the links to the product details pages from the product listing page of a WooCommerce store. If this article has helped you then please leave a comment :smiley:

Thanks for reading!