I am working on a personal project that is set up in a way that each post will have only one media file attached (wav audio) and no imagery or other media at all. I am using rtmedia to transcode the uploaded wav file to mp3 and have the mp3 version playable in the browser with the default WordPress audio player.
I've uploaded an audio file that was given the media ID of 6, and shows up fine when I just hard code the ID for testing into the shortcode using
<?php echo do_shortcode( '[rt_media attachment_id= 6]' ); ?>
But I am not entirely sure of the syntax I would need to have the media ID change depending on what post it was attached to.
Something like the following, but doesn't work, nor did I really expect it to.
<?php
$values = get_attached_media( 'audio' );
echo do_shortcode( '[rt_media attachment_id= '. $values[0] .']' );
?>
I'm not a coder, so please forgive my sloppiness.