Archived topic
Buzzsprout player in hero element
3 replies · Started by Adam on July 26, 2021
Hi, I'm trying to add the buzzsprout player to my hero, in a generate_after_header hook. I used to do this with blurry powerpress and simple podcast player, where I could add a [spp-player] shortcode, and then configure the podcast through the powerpress plugin.
But for buzzsprout, I need to enter the episode number (it's a shortcode like [buzzsprout episode='8926847' player='true']) - and I'm wondering if there is a way to create a variable in a post and save the number '8926847', such that I could reference it in the element? Does that make sense?
Example -
https://peoplehelpingpeople.world/2021/07/22/david-aspinall-auticon/
How this was previously -
https://peoplehelpingpeople.world/2021/07/08/dr-lynda-ulrich-of-ever-widening-circles/
My element hook -
<?php
<div class="adam-podcast-hero">
<div class="adam-podcast-hero-meta">
<h1 class="blog-page-title"><?php the_title(); ?></h1>
<span class="blog-meta-date-display"><?php the_time(get_option('date_format')); ?></span> |
<span class="blog-meta-author"><a href="/about"><?php the_author(); ?></a></span> |
<!--span><--?php $EpisodeData = powerpress_get_enclosure_data(get_the_ID(), 'podcast'); echo $EpisodeData['duration'];?></span> | -->
<a href="<?php the_permalink(); ?>/#comments"><?php
$c_num = get_comments_number();
if ($c_num != 1){
echo "{$c_num} Comments";
} else {
echo "{$c_num} Comment";
}?></a>
<br/><br/><br/><br/>
[spp-player]
</div>
</div>
Hi there,
You'll need a custom field associated with the post that takes the number.
You then fetch it to the shortcode using get_field('field_slug_here',get_the_ID());
Example:
do_shortcode('[buzzsprout episode="'.get_field('your_field_slug_here',get_the_ID());.'" player='true']');
Thanks so much, Elvin - I'm new to making my own custom values... that worked great!
Learning how to do it opens up so many possibilities. :)
Glad you got it to work. No problem. :D