WooCommerce: Disable Link to Single Product @ Shop

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!

WooCommerce: Disable Product Links on the Shop/Archive page
WooCommerce: Disable Product Links on the Shop/Archive page

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        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @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 );

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: Disable Variable Product Price Range $$$-$$$
    You may want to disable the WooCommerce variable product price range which usually looks like $100-$999 when variations have different prices (min $100 and max $999 in this case). With this snippet you will be able to hide the highest price, and add a “From: ” prefix in front of the minimum price. At the […]
  • WooCommerce: Hide Price & Add to Cart for Logged Out Users
    You may want to force users to login in order to see prices and add products to cart. That means you must hide add to cart buttons and prices on the Shop and Single Product pages when a user is logged out. All you need is pasting the following code in your functions.php (please note: […]
  • WooCommerce Visual Hook Guide: Archive / Shop / Cat Pages
    I’ve created a visual HTML hook guide for the WooCommerce Archive Page (which is the same page for the Shop, Category, Tag pages). This visual guide belongs to my “Visual Hook Guide Series“, that I’ve put together so that you can find WooCommerce hooks quickly and easily by seeing their actual locations (and you can […]
  • WooCommerce: Hide Prices on the Shop & Category Pages
    Interesting WooCommerce customization here. A client of mine asked me to hide/remove prices from the shop page and category pages as she wanted to drive more customers to the single product pages (i.e. increasing the click-through rate). As usual, a simple PHP snippet does the trick. I never recommend to use CSS to “hide” prices, […]
  • WooCommerce: How to Remove the “Default Sorting” Dropdown
    If the WooCommerce product sorting functionality (“Default Sorting” dropdown) is a waste of space or you don’t need that select box at all, you may want to remove it. No matter if you prefer custom code or a simple plugin – hiding the product sorting dropdown is a piece of cake. Enjoy!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

69 thoughts on “WooCommerce: Disable Link to Single Product @ Shop

  1. 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!!!

    1. 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!

  2. yes working thank you

  3. 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.

    1. Hello Maurus, yes, you’ll need to add some custom code because of Astra theme

      1. Hi Maurus, was you able to disable it using astra? I have the same problem.

  4. It worked perfectly for me! Thank you!

    1. Great!

  5. Thanks it worked to remove link from product, but i want to keep link on title. How can I do that? Please help.

    1. 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!

  6. 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

    1. If you don’t have “?>” at the end, place it on the last line. Otherwise, the second last.

  7. 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

    1. It could be because of your custom theme. Try temporarily switching and see if it works with 2020 theme

  8. 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

    1. 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!

  9. Hi Rodolfo!
    I need this only for one CATEGORY.
    thanks and regards from Milan

  10. 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

    1. 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

  11. Works perfect! Woocommerce Version 3.5.4
    Thanks for that!

    1. Excellent!

  12. 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

    1. 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

  13. Works great, and used in conjunction with the CSS-Javascript-Toolbox plugin I can run this on selected pages.

    1. Excellent 🙂

  14. Still works great with WooCommerce 3.4.5 under WordPress 4.9.8. Thanks for the snippet.

    1. Excellent!

  15. 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.

    1. 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

  16. 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

    1. 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

  17. 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

    1. Cheers Liran 🙂 Great, I will add this to my to-write list!

  18. For what it’s worth it didn’t work on WC 3, although I think template or custom category list was toy’d with…

    1. 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 🙂

  19. Thanks for your post.. It really helped me!!

  20. 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?

    1. 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 🙂

  21. 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

    1. 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

  22. Works like a charm, just dropped it in the theme’s function file and boom, worked flawlessly.
    Thanks a lot for the snippet.

    1. Thanks so much for your feedback Darwin!

  23. thank you so much …

    1. You’re welcome Mounish!

  24. Can someone help me how can I Disable Link to only SOLD Products? Thanks.

    1. Szabi, thanks so much for your comment! Did you mean the “Out of Stock” products?

      1. 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:

        function remove_direct_link_to_product_page() {
        if ( is_product_category( ‘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 );
        }
        }
        

        (I’ve probably got it coded wrong) any thoughts about this?

        1. 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!

          1. 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.

            function remove_direct_link_to_product_page() {
            if ( has_term( 'sold', 'product_cat' ) ) {
            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 );
            }
            }
            
            1. 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”?

              1. 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.

                1. That doesn’t seem to be my code, sorry but I can’t help 🙂

  25. 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

    1. 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

  26. How do I remove the product link from the cart page?

    1. 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!

  27. Using the default Twenty Sixteen theme would it be possible to do this only for external products or specific categories?

    1. 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!

  28. Sorry the silly question but where (file) I put this code? tks

    1. 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

  29. 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 );
    

    Does not seem to work for me…. 🙁

    Storefront child theme 2.1.2
    Woocommerce 2.6.4
    WP : 4.6.1

    any ideas ?

    1. 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!

      1. 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 );

        1. Ahah excellent! Yes, those “single quotes” are a real pain when copying/pasting PHP snippets in your text editor. Well done!

  30. 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.

    1. 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!

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *