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.
You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). 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.3.
Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!
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.
32 thoughts on “WooCommerce: Change Product Permalinks @ Shop / Loop Pages”
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! 🙂
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!
Thanks for the snippet, but the permalinks linked to the product title is not getting changed, any means to change that too?
Hi Sam, are you on a custom / non default theme?
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!
Is the product name linking to the exact URL you set up in the redirect?
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
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!
Would this still work for a product category as well?
Nope, need a different snippet for that
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.
That’s not possible, there must be a bug. Try switching to 2020 and disable all plugins but Woo, then test again
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.
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!
Thank you Rudolfo! Is it possible to change the checkout permalink of only one product?
Yes! I suggest you take a look at “conditional logic”: https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/. Let me know 🙂
thank u so much Mr.Rodolfo , your code is clean and simple , my problem solve now .
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?
Try removing the .com from the URL. Also, can you paste here the snippet you used?
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.
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!
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:
Sub category: blue_cars
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?
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!
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
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
the code is not working anymore on the latest wordpress and woocommerce version.
Can you take a look and test again?
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!
hello and thank you for this?
can do it with redirect plugin easily, any diffrence between redirect trough and your sulution?
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 🙂
Hey! Appreciate you creating this tutorial for me Rodolfo 🙂