We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question, Addons, Podcasts

How do I get the most recent podcast episode and display it?

I haven't worked with perch in months and have forgotten how to do so many things. I'm working on a site for a podcast, and the client would like to display the most recent podcast episode on their home page. I thought it would be something like this, except the available options for that function doesn't include a count or sort-order, and it doesn't seem to actually do anything.

  <?php perch_podcasts_episode(perch_get('show-slug'), perch_get('ep'), array(
'template' => 'episode.html',
  'sort-order' => 'DESC',
  'count' =>1
)); ?>
Gary Iverson

Gary Iverson 0 points

  • 3 years ago
Simon Clay

Simon Clay 127 points

I think that's because your code is looking for a query string in the url to identify what podcast to show.

Does this work?:

<?php perch_podcasts_shows(array(
  'template' => 'episode.html',
  'sort-order' => 'DESC',
  'count' => 1
)); ?>

That works, in that it pulls the template, but it doesn't display any of the content within the template for the episode itself, such as the title and description.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What's in your template?

Don't you need to use perch_podcasts_episodes rather than shows?

Then those options with the template should work. So:

<?php 
perch_podcasts_episodes('show-slug', [
'template' => 'my_episode_template',
'sort-order' => 'DESC',
'count' => 1
]);
?>

Dexter, that does exactly what I needed it to do. I was close-ish.