Product Archive

WooCommerce Redirect Product Links On Archive Page

WooCommerce product redirecting to custom URL

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

This snippet stops the user from being able to the view the single product template and instead redirects them to a user defined URL. In this specific example, we redirect users to our guides page if they try to view any product page. This may be useful if you require customers to fill out a form, login to their account, or complete some other action before being able to view a product.

/**
 * Snippet Name:	ecommercehints.com
 * Snippet Author:	WooCommerce Redirect Product Links On Product Archive
 */

add_action( 'template_redirect', 'ecommercehints_redirect_product_links', 10 );
function ecommercehints_redirect_product_links() {
    if (!is_product()) return;
    wp_redirect( 'https://ecommercehints.com/guides' ); // redirect to this URL.
    exit();
}

Snippet Benefits

  • Redirect product pages to custom URLs

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.

26027
WELCOME OFFER