Today we take a look at the WooCommerce Loop / Shop Page and specifically at how to disable the link to the single products.
Some store owners prefer to skip the single product page, and simply have customers add to cart from the shop page. Enjoy!

PHP Snippet: Disable Link to Products @ WooCommerce Shop / Category / Loop Pages
Thank you Daymobrew for your very elegant alternative to my initial hack 🙂 I love when 2 lines of code achieve a better result than 10!
/**
* @snippet Disable Link to Products @ Loop
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @testedwith WooCommerce 4.0
* @community https://businessbloomer.com/club/
*/
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 );
Hi! I am using blocksy theme(free version) and it didn`t work for me. It is about removing ling to product in image. Help me please!!!
Thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
yes working thank you
Nice!
Hi,
Unfortunately this didn’t completely fix it for me. I was able to disable the Link that is attached to the product picture not however the link within the Product title. Any advice?
Do I have to address a different function or us a different hook?
I´m using “Astra” and my WooCommerce is on the latest version.
Hello Maurus, yes, you’ll need to add some custom code because of Astra theme
Hi Maurus, was you able to disable it using astra? I have the same problem.
It worked perfectly for me! Thank you!
Great!
Thanks it worked to remove link from product, but i want to keep link on title. How can I do that? Please help.
Hi Arifa, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
sir in functions .php where to paste it??? i am unable to find (before “?>” if you have it).
Can You tell me identity where to paste it ???
HElp me
Or tell me line no. or some identity where i have to plce this
If you don’t have “?>” at the end, place it on the last line. Otherwise, the second last.
For me it is not working… and I put your code but is not working, you can click the product and go to the single product page…
i have last WC and WP version.
thank you very much Angelo
It could be because of your custom theme. Try temporarily switching and see if it works with 2020 theme
Hi, thank you so much for the code! It worked perfectly for my product image, however I would like to remove the link from the product name too.
Please could you help me with that?
Thanks
Hi China, your theme is probably overriding default WooCommerce so this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi Rodolfo!
I need this only for one CATEGORY.
thanks and regards from Milan
Ciao Jaume, I suggest you take a look at “conditional logic”: https://businessbloomer.com/conditional-logic-woocommerce-tutorial/ and https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/. Let me know 🙂
Hello,
Thank you for the code I was looking very useful !!
I’m creating an affiliate site and would like to remove the existing link from the title as in your example and would like to add my affiliate link instead.
Can you help me ?? How does one ??
Thank you for your help
Hello Aymeric, thanks so much for your comment! Yes, this is possible – unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R
Works perfect! Woocommerce Version 3.5.4
Thanks for that!
Excellent!
Hello
Im new @ this
I have a website that use woocomerce
im adding products that link to amazon in different categories
When i use the woocomerce shortcode to show the products in each categoty
The product links first to the single product page then to amazon
I want to link the product to amazon instead of going to my single product page
how i would be able to change this
Hi Robert, thanks so much for your comment! Yes, this is possible – unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R
Works great, and used in conjunction with the CSS-Javascript-Toolbox plugin I can run this on selected pages.
Excellent 🙂
Still works great with WooCommerce 3.4.5 under WordPress 4.9.8. Thanks for the snippet.
Excellent!
Hi,
Thank you, this works.
BUT my product is set to allow only one per order.
I also use AJAx to redirect to CART
But when a user try to add a product already in the cart, it redirects to the single product page.
Hope you can help.
thank you.
Hey Schalk, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
Hi Rodolfo,
how would you go about making it so if it’s an external product, the link redirects to the external product instead of the internal page?
Thank you
Mathilde, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
Hi Rodolfo,
I love your snippets and use them all the time!
There is one snippet I wish for that is very similar to this one….
I wish to disable links to products from the cart and the mini-cart.
Hope you’ll get to it 2 soon
Cheers Liran 🙂 Great, I will add this to my to-write list!
For what it’s worth it didn’t work on WC 3, although I think template or custom category list was toy’d with…
Hey Wilbur, thanks for your comment! It should work with Woo 3, therefore I believe your theme is overriding the default behaviors and changing the hooks/PHP 🙂
Thanks for your post.. It really helped me!!
Great 🙂
Hi,
I’m a beginner to actions and functions and am trying to reverse engineer this. My theme has a link on the thumbnail but not the title (on the archive page), how could I make the title also link?
Hey Liam, thanks for your comment! You will need to take a look at your theme’s coding, as they’re likely overriding the WooCommerce default behaviour 🙂
its awesome. worked for me but 1 issue. it disabled mouse wheel scrolling on that page.
i can not scroll through mouse wheel after adding that code in my functions.php file
Hello Ibtesam, thanks for your comment! I’m not sure your problem is related to my snippet, it’s just PHP and cannot affect the mouse wheel 🙂 Thank you, R
Works like a charm, just dropped it in the theme’s function file and boom, worked flawlessly.
Thanks a lot for the snippet.
Thanks so much for your feedback Darwin!
thank you so much …
You’re welcome Mounish!
Can someone help me how can I Disable Link to only SOLD Products? Thanks.
Szabi, thanks so much for your comment! Did you mean the “Out of Stock” products?
Yes. Adding the above code has removed the links from products.
However, I want to target only on “out of stock” products or for a specific category (even better).
Tried the following and didn’t work:
(I’ve probably got it coded wrong) any thoughts about this?
Yes, indeed 🙂 You’re using a conditional tag that only works on the category page, and not the single product page. Try looking at https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/ to find the right tag. Let me know!
Thanks a lot Rodolfo for your prompt reply, I’m still looking for the solution.
Just to clarify I want the condition to work only on each product on the loop pages based on a category.
The following code didn’t remove the product links under the category named ‘sold’, however, when I echoed something that was working…waiting for your answer, thanks.
Your single quotes > ‘ are all over the place, but PHP would give you error I guess. When and how are you triggering the function “remove_direct_link_to_product_page”?
Thanks again for your comment Rodolfo.
I’ve corrected the quotes, however I’m not sure how I’m triggering the function :
“remove_direct_link_to_product_page”
I’ve actually just found this solution while I was browsing for hours.
Still no success removing the links for products inside a category.
That doesn’t seem to be my code, sorry but I can’t help 🙂
Hi Rodolfo,
i´ve got a question, is it possible to redirect the link from the image and text to the single product page to a external page?
Thank you
Hey TBone, thanks for your comment! Sure, of course there is a way to implement that on the single product page – but unfortunately this is custom work and I cannot provide a complementary solution here on the blog. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R
How do I remove the product link from the cart page?
Hey Ram, thanks for your comment! You can do so by using something similar to this: https://businessbloomer.com/woocommerce-remove-permalink-product-order-table. However, you’ll need to find the exact filter that is on the cart page, instead of the order page 🙂 Hope this helps!
Using the default Twenty Sixteen theme would it be possible to do this only for external products or specific categories?
Hey Syrehn, thanks so much for your comment! Of course this is possible, and it’s 100% independent from the theme you use. All you need is checking out this guide https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/ and you’ll be able to run this snippet only when a certain condition is met 🙂 Good luck!
Sorry the silly question but where (file) I put this code? tks
Erica, thanks for your comment! No question is ever silly 🙂
You can place this in your child theme’s functions.php file – if you need more guidance, please take a look at this video tutorial: https://businessbloomer.com/woocommerce-customization-hangout/
Let me know, ~R
Does not seem to work for me…. 🙁
Storefront child theme 2.1.2
Woocommerce 2.6.4
WP : 4.6.1
any ideas ?
Hey Marc, I just tested it with the exact same versions and the product image and product title links in the shop/category page are correctly disabled! You have to remove the Add to Cart as well, but those 2 remove_action work perfectly 🙂 Not sure!
Got it !
‘ and not ‘
remove_action(‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_product_link_close’, 5 );
remove_action( ‘woocommerce_before_shop_loop_item’, ‘woocommerce_template_loop_product_link_open’, 10 );
Ahah excellent! Yes, those “single quotes” are a real pain when copying/pasting PHP snippets in your text editor. Well done!
Another idea: remove the actions that open and close the links:
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 );
I would have to look further where to include these calls, to ensure that they happen *after* the corresponding add_action() calls.
Awesome Damien!! It works on my dev site as well, so there is no need to “delay” the remove_action. I’m adding the solution to the blog 🙂 Keep it coming!