Redirect product category to product ID in WooCommerce

Redirect product category to product ID in WooCommerce on child sites.

Snippet Type

Execute on Child Sites

Snippet

add_action( 'wp', 'wc_redirect_cat_to_product' );
  
function wc_redirect_cat_to_product() {
   if ( is_product_category( 'tables' ) ) {
      wp_safe_redirect( get_permalink( 123 ) ); // PRODUCT ID
      exit;
   }
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.