Essentially, right now my only options are to place the player:
1) At the very beginning of the post
2) At the very end of the post
3) Nowhere in the post
I’ve actually written my own custom shortcode to accomplish this on our site for the time being. I did this so that we could place the player in the correct location for this post:
https://www.esupplements.com/best-l-glutamine-supplements/
We have that left-floating meta-information section that comes first in the article, and we wanted the player to show up at the “top” of the article content but after that meta-information section.
Here’s my custom code:
function amazon_polly_player_shortcode($atts, $content = NULL) {
global $post;
$tagged_content = '';
if(intval(get_post_meta($post->ID, 'amazon_polly_enable', TRUE))===1) {
$player_source = get_post_meta($post->ID, 'amazon_polly_audio_link_location', TRUE);
$tagged_content = PHP_EOL.'-AMAZONPOLLY-ONLYWORDS-START-'.PHP_EOL.'
<table id="amazon-polly-audio-table">
<tbody>
<tr>
<td id="amazon-polly-audio-tab">
<div id="amazon-polly-label-tab">Listen to this article</div>
<div id="amazon-polly-play-tab">
<audio id="amazon-polly-audio-play" preload="none" controls="">
<source type="audio/mpeg" src="'.$player_source.'">
</audio>
</div>
<div id="amazon-polly-by-tab">
<a href="https://aws.amazon.com/polly/" target="_blank" rel="noopener noreferrer">
<img src=" https://d12ee1u74lotna.cloudfront.net/images/Voiced_by_Amazon_Polly_EN.png" width="100">
</a>
</div>
</td>
</tr>
</tbody>
</table>'.PHP_EOL.'-AMAZONPOLLY-ONLYWORDS-END-'.PHP_EOL;
} else {
$tagged_content = PHP_EOL.'<!-- Amazon Polly not enabled on this post -->'.PHP_EOL;
}
return $tagged_content;
}
add_shortcode('polly_player', 'amazon_polly_player_shortcode');
Then I just put the [polly_player] shortcode in my content where I wanted the player to render. Seems to be working great for us, and it provided the ability to customize the post to how we wanted it to be.