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
* @donate $9     https://businessbloomer.com/bloomer-armada/

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 this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7+.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce Customization?

Check out these free video tutorials. You can start learning how to customize WooCommerce without unnecessary plugins. Watch me code and learn by example!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a 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.

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

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

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

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

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

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


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

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

    1. 🙂

Questions? Feedback? Support? Leave your Comment Now!

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

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