Do you want to redirect product pages to the home page or any other page? Well, this small snippet will help you. You don’t need to use any plugin. This little snippet will do the work.
/** * @snippet WooCommerce Redirect single product pages to home page * @author Sandesh Jangam * @donate $7 https://www.paypal.me/SandeshJangam/7 */ add_action( 'wp', 'ts_redirect_product_pages', 99 ); function ts_redirect_product_pages() { if ( is_product() ) { wp_safe_redirect( home_url() ); exit; } } // PS. - You can replace home_url() to your specific URL also.
4 thoughts on “WooCommerce: Redirect single product pages to home page”
This snippet saved me alot of time and money.
it does the trick.
Thanks Sandesh!
I’m glad I was able to help. Thanks for the comment.
Nice tutorial,
thanks for source.
Need some help,
Is this possible, when we click “Buy Now” on the shop page, it will auto redirect to simple_page/contactpage? https://prnt.sc/uzifqb
I have used this: https://prnt.sc/uziglf for “Add to cart” go to redirect simple_page/contact page
I want for use, also Buy now go to the same page, how it’s possible.
NB: Only for some products.
It is definitely possible. You can add Buy Now button using some hook. Just append it before Add to cart with direct contact page link. You can contact me for custom work. Thanks.