I am trying to add the default WordPress audio shortcode to the content-single-product.php for WooCommerce template. I am having trouble specifying the correct src so that the audio shortcode populates with the audio files attached to the post.
The code I’m using is:
$ca_audio = $product->get_id();
$attr = array(
‘src’ => $ca_audio,
‘loop’ => ”,
‘autoplay’ => ”,
‘preload’ => ‘none’
echo wp_audio_shortcode( $attr );
This is pulling the correct Product ID but only displaying it as a number, not a player. If I leave ‘src’ blank it shows a player skin, but again no audio plays. If I specify a direct link into the ‘src’ field it will play the file correctly. I need this to auto populate for every post on the site however and I am not sure how to get the src automatically for each.