If you add it to the correct hook then it will become a link automatically (since WooCommerce has action hooks INSIDE the <a>
link tag.
function kia_add_subtitle_to_woocommerce(){
if( function_exists( 'the_subtitle' ) ){
the_subtitle( '<h2 class="subtitle">', '</h2>' );
}
}
add_action( 'woocommerce_shop_loop_item_title', 'kia_add_subtitle_link_to_woocommerce' );
To make a link somewhere else (in the loop) to you need to the link to the_subtitle()
before and after parameters.
function kia_add_subtitle_link_to_woocommerce(){
if( function_exists( 'the_subtitle' ) ){
$link = the_subtitle( '<h2 class="subtitle"><a href="%s" title="%s">', '</a></h2>', false );
printf( $link, get_permalink(), sprintf( __( 'Permalink to %s', 'your-text-domain' ), get_the_title() ) );
}
}
add_action( 'some_custom_hook', 'kia_add_subtitle_link_to_woocommerce' );