Home Redirect product pages to another site
Reply: 0

Redirect product pages to another site

user1036
1#
user1036 Published in June 20, 2018, 10:41 pm

This is a bit of a odd situation, of needing to recode WooComm to send visitors to a separate website as their store-front (I didn't ask why, I'm just paid to "make it happen.") I've figured out thanks to StackOverflow how to do a, I guess "basic" redirect, but I need to be able to redirect something around 20 product pages to their respective mirror-products on the other site.

Below is some simple code I found here, but I need to modify slightly. The "if(is_product))" I'd like to refine to be specific to each product and to send to their mirror-products. I'm sure there's a better method, but I'm still very very new to this level of coding. And for security reasons, I'm using Google as the redirect destination for posting the code here.

add_action('template_redirect','custom_shop_page_redirect');
function custom_shop_page_redirect(){
if (class_exists('WooCommerce')){
    if(is_product()){
        wp_redirect( 'https://google.com' );
        exit();
    }
} 
return;
} 
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.315235 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO