asked 5 years ago

Hi there,
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.

Dominic Staff
replied 5 years ago

You can try the following code:
‘src’ => strip_tags($ca_audio),
Hope this helps!

replied 5 years ago

Hey Dominic,

Thanks for the reply. That code doesn’t seem to help, it just shows the product ID as a number in place of the player.

I can’t figure out what I need to use for the ‘src’ to have it find the actual attachments. Right now I’m getting the Product ID, but not pulling the attached audio.

Dominic Staff
replied 5 years ago

Yes, I sent and notified to our technical team about this issue, we will check and discuss about it.

Powered by DW Question & Answer Pro