Hi.
My landing page kuechenstud.io used to show the subtitle of the latest show:
<?php echo do_shortcode('[podlove-episode field="subtitle"]'); ?>
After one of the latest updates it doesn´t work anymore.
How do I use template tags to show the subtitle of the latest show again?
Thanks.
Hi!
The corresponding template tag to [podlove-episode field="subtitle"]
is {{ episode.subtitle }}
, so maybe just replacing that does the trick. I’m not familiar with wrapping it in this PHP code, though.
Hope this helps.
Thanks - but no
Doesn´t help.
Hm… kuechenstud.io now shows [podcast.subtitle]
to the template engine itself seems to work. But where do the square brackets come from? I think they are the deal breaker here. Can you maybe post your entire template code here?
Right now kuechenstud.io shows {{ episode.summary }}.
The whole code of the landing-page is:
<?php
/*
Template Name: Landing Page
*/
?>
<?php get_header(); ?>
<?php if ( have_posts() ) the_post(); ?>
<section id="landing-info">
<?php the_content(); ?>
</section>
<section>
<ul id="show-list" class="landing">
<?php
$shows = get_blogs_of_user(1);
// print_r($shows);
global $post;
$args = array(
'numberposts' => 1,
'post_type' => 'podcast' );
foreach ($shows as $show) {
switch_to_blog($show->userblog_id);
$episodes = get_posts( $args );
foreach ($episodes as $post ) {
setup_postdata($post);
?>
<li class="<?php echo str_replace('/','',$show->path); ?>">
<div class="show-head">
<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>">
<h2><?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?></h2>
<img src="<?php header_image(); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" />
</a>
<div class="player-small">
<?php // echo do_shortcode('[podlove-web-player]'); ?>
</div>
</div>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php echo do_shortcode(' {{ episode.summary }} '); ?>
</li>
<?php
}
}
switch_to_blog(1);
?>
</ul>
</section>
<?php get_footer(); ?>
OK, thanks. @ericteubert: I’m at the end of my knowledge & intuition here, sorry.
There’s no official way yet to access Publisher data from within themes, but this will work here:
<?php
$episode = \Podlove\Model\Episode::find_one_by_post_id(get_the_ID());
echo $episode->summary;
?>
1 Like
Great. Works. I only changed
$episode->summary
to
$episode->subtitle
Thanks!
This whole podcast overview page could be done much simpler with a single Podlove Template that would need no theme support or PHP intervention at all.
This is not a complete instruction, just from the top of my head and untested:
First create a list of podcasts named “kuechenstudio” in Network -> Lists
. and add all relevant podcasts to it.
Then create a template named “kuechenhome” in Network -> Templates
with the following contents:
<ul>
{% for podcast in network.lists({id: "kuechenstudio"}).podcasts %}
<li>
<a href="{{ podcast.landingPageUrl }}" title="{{ podcast.title }}">
{{ podcast.image.html({ width: icon_size }) }}
</a>
<div class="player-small"/>
{% for episode in podcast({ limit: 1 }) %}
<h3>
<a href="{{ episode.url }}">
{{ episode.title }}
</a>
</h3>
{{ episode.subtitle }}
{% endfor %}
</li>
{% endfor %}
</ul>
Then put this shortcode into the page that is representing the home page:
[podlove-template template="kuechenhome"]
This should more or less do what you are doing now.