I am using the WooCommerce plugin.
I want to redirect the user to shop page if they try to access the product link.

For example, this is the product link: http://www.example.com/product/av and shop page link: http://www.example.com/shop

Now when a user tries to visit a product link, should be redirected to the shop page!

Mainly, I don't want anyone to have an access to the product page!

Please, can someone tell me how can I achieve this?

Thanks in advance!


You can try using template_redirect action hook to check if the current page is product page and after that, you can redirect the user to your shop page.

Paste this code into your functions.php

function custom_shop_page_redirect(){
    if (class_exists('WooCommerce')){

I have not tested it, but hope it will work for you.

  • Currently it redirects even the url used for product edit. How can I restrict this redirection for view product url only? – Himani Feb 16 '18 at 10:54
  • As you described your problem, the above code redirect frontend users from the single product page to shop page. Can you explain it more by an example what exactly you want to do? Thanks – Harry Feb 16 '18 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.