WooCommerce: Change Product Permalinks @ Shop / Loop Pages

A BloomerArmada fan asked me a very interesting question: how can I link each product in the shop page to its own custom landing page as opposed to the default permalink?

Of course this applies when you don’t want to use the default single product page for all or some products. Clearly, you could set up a 301 redirect from the single product page to the landing page – that will help for SEO as well. But if this is temporary, or you need to still give access to the single product page later on, then a redirect is no good.

So, here’s how you can override the default permalink.

Linking a product to a custom landing page URL instead of the default WooCommerce single product permalink

PHP Snippet: Change Product Links @ WooCommerce Shop / Loop Pages

Thankfully, the woocommerce_template_loop_product_link_open() function, which is responsible for the product “a href” in the loop pages, contains a filter called woocommerce_loop_product_link

You can therefore change that link with add_filter() and return your custom URL instead of the default permalink.

It even gives you access to $product, which means if you have the custom URL saved in a custom field, you can return that programmatically.

* @snippet       Change Product Permalinks @ WooCommerce Shop
* @how-to        Get CustomizeWoo.com FREE
* @author        Rodolfo Melogli
* @compatible    WooCommerce 4.0
* @community     https://businessbloomer.com/club/

add_filter( 'woocommerce_loop_product_link', 'bbloomer_change_product_permalink_shop', 99, 2 );

function bbloomer_change_product_permalink_shop( $link, $product ) {
   $this_product_id = $product->get_id();
   if ( $this_product_id === 25 ) $link = '/custom-landing-page';
   return $link;

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: Add Second Description @ Product Category Pages
    In terms of SEO, if you’re trying to rank your product category pages, you really need to make the most of the default WooCommerce product category “description” and “thumbnail”. Most themes, if compatible with WooCommerce, will show this content right below the product category name and above products. Nothing new so far. But what if […]
  • 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, […]

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

32 thoughts on “WooCommerce: Change Product Permalinks @ Shop / Loop Pages

  1. There was a posibility to modify also the target type? We are changing the link, but, I would like to set its target as “_blank”.

    This is possible?

    Thanks, for sharing! 🙂

    1. Hello Ferran, 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. Hi,
    Thanks for the snippet, but the permalinks linked to the product title is not getting changed, any means to change that too?


    1. Hi Sam, are you on a custom / non default theme?

  3. Hello everyone!

    I hope you can help me. Unfortunately, I am very new to coding, but I want to find a solution to a problem.

    I would like some products to be loaded with a landing page instead of the “traditional woocommerce” product page. I used the code mentioned above and I was very happy (thank you very much again !!!) because it works.

    There is a tiny problem (this is an interesting phenomenon for me). On the product category pages, if I click on the product name, it will load the “traditional woocommerce product page”, and if I click on the image, it will load the landing page set by the code mentioned above. 🙁 I would like the mentioned landing page to load even if I click on the product name for each product. Maybe I need to add a detail to the mentioned code. Could someone help? I would be very grateful!

    Theme I use: Astra
    Page builder: Gutenberg + UAG

    Thank you very much in advance!

    1. Is the product name linking to the exact URL you set up in the redirect?

  4. first thank you for this tutorial

    my problem is i tried this code but it is not working with my theme because when i deactivatedthe theme it is work fine
    but i can’t change my theme so i don’t know what to do can you help me please

    thank you

    1. Hi Achraf, thanks so much for your comment! Yes, this is definitely fixable, 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!

  5. Would this still work for a product category as well?

    1. Nope, need a different snippet for that

  6. Hi Rodolfo,

    Thanks for this article, this solution works only when you render the products on the first page.

    As soon as you move on to clicking on pagination links – 2, 3 ,4 etc., the product loop filter no longer works. Is there a separate filter I should be considering for products rendered via ajax calls.

    Many thanks for your help.

    1. That’s not possible, there must be a bug. Try switching to 2020 and disable all plugins but Woo, then test again

  7. Do you have a similar solution for the “add to cart” button? I would like to specify where the button leads to for each product. Thanks.

    1. Hi Ken, 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!

  8. Thank you Rudolfo! Is it possible to change the checkout permalink of only one product?

    1. Yes! I suggest you take a look at “conditional logic”: https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/. Let me know 🙂

  9. thank u so much Mr.Rodolfo , your code is clean and simple , my problem solve now .

    1. Nice!

  10. Hello Rodolfo,

    I have tried to apply the code as per your instruction given to Surguci with Twentyseventeen hteme and all plugins disabled except WooCommerce (my current version is 4.0.1) and WordPress 5.3.2 and it does not work. Can you give me instructions on what is happening?


    1. Try removing the .com from the URL. Also, can you paste here the snippet you used?

  11. Hello Rudolfo,

    I found your very helpfull Snippet. But I have some trouble with it – because it doesn’t work. I use the Lahanna Template. And I created a page with a block. At this block I placed a woocommerce-widget to show products from only one brand. But I need to change the link to our “main shop” at an other Domain. I have a page with all products from all brands and so on and here I changed the function “woocommerce_before_shop_loop_item” and it works propper….
    But on my “Brand-Page” your Snippet won’t run. And I’m wondering why 🙂
    Is a widget placed on a WordPress-Page still a Woocommerce Thang, or is it a Word-Press-Thang. And I need to customice a WordPress-Link-Template?
    I hope you can understand, what I’m asking for – and you can give me some advisr or tips, how I can solve my problem.

    THank you very much, for your support.

    1. Hello Jorg, 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!

  12. Rodolfo you’re the man! Great tip as always!
    I wonder if it’s possible to make all product links point back to their sub category and not the product page?

    Let’s say we have this:

    Category: cars
    Sub category: blue_cars
    Product: blue_car

    I would like this link:
    to point to:

    Can it be done with one little snippet instead of creating many different variations of this snippet?

    Many thanks!

    1. Hello Teddy, 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!

  13. Hi Rodolfo,

    Read your post on 21+ SEO optimization tips for WooCommerce and this post really is the core of an issue I am facing.

    My family business is a cosmetics site and is small scale so no real budget for hefty development.

    So I am pretty savvy with WordPress development but am weak on SEO.

    I want to create a unique and customised product page for each product to give a unique experience for each one. I am using the WooCommerce product page shortcodes which gives me greater flexibility on the page layout. However, if I use a 301 from the original product to the new design, will I trash my SEO?

    I also considering just swapping the permalink structure and sliding the new custom pages in place of the old original WooCommerce product pages. Then a noindex on the default content as it would display on the custom pages and I want to avoid duplicates

    However would you recommend the suggestion in this post above the ideas I added above?

    Any guidance would be appreciated. Thanks

    1. Hi there – ideally the best would be to keep using your original product pages, and customize them (example: https://businessbloomer.com/customize-single-product-page/). Otherwise, a 301 redirect is no problem either – it really depends on how much you need to customize product pages

  14. Hello,
    the code is not working anymore on the latest wordpress and woocommerce version.
    Can you take a look and test again?

    1. It should work – are you linking to the same website, right?

      To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentyseventeen” theme (load the snippet there in functions.php) – does it work? If yes, you have a problem with your current theme or one of the plugins.

      Hope this helps!


  15. hello and thank you for this?
    can do it with redirect plugin easily, any diffrence between redirect trough and your sulution?
    thank you

    1. Hey Saeed, thanks for your comment! No difference, no – but for a few redirects it may be easy to keep them all together into a single snippet 🙂

  16. Hey! Appreciate you creating this tutorial for me Rodolfo 🙂

    1. 🙂

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 *