# \[Solved\] How to access post thumbnail from Twig template?

**URL:** <https://community.podlove.org/t/solved-how-to-access-post-thumbnail-from-twig-template/651>\
**Category:** Podlove Publisher\
**Created:** [July 27, 2016, 9:20am UTC](https://community.podlove.org/t/solved-how-to-access-post-thumbnail-from-twig-template/651 "2016-07-27T09:20:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![funkenstrahlen](https://community.podlove.org/user_avatar/community.podlove.org/funkenstrahlen/32/281_2.png) [@funkenstrahlen](https://community.podlove.org/u/funkenstrahlen)\
**Post date:** [July 27, 2016, 9:20am UTC](https://community.podlove.org/t/solved-how-to-access-post-thumbnail-from-twig-template/651/1 "2016-07-27T09:20:28Z")

</div>

I am working on a twig template showing related episodes.

```
<!-- ===== RELATED EPISODES ===== -->
{% for episode in episode.relatedEpisodes %}
	<div class="podcast-card sidebar">
		<figure class="podcast-image"><a href="{{episode.url}}">{{episode.post.the_post_thumbnail('episode-box')}}</a></figure>
		<div class="podcast-content">
			<span class="podcast-date">{{episode.publicationDate}}</span>
			<h2 class="podcast-title"><a href="{{episode.url}}">{{ episode.title }}</a></h2>
		</div>
	</div>
{% endfor %}

```

This works perfectly except for the post thumbnail. I do not want to show the episode coverart!

I tried using this `{{episode.post.the_post_thumbnail('episode-box')}}` but it does not work. I use `$post->the_post_thumbnail('episode-box')` everywhere in my PHP code, so the function is available.

---

<div class="post-metadata">

**Author:** ![ericteubert](https://community.podlove.org/user_avatar/community.podlove.org/ericteubert/32/1568_2.png) [@ericteubert](https://community.podlove.org/u/ericteubert)\
**Post date:** [July 27, 2016, 10:14am UTC](https://community.podlove.org/t/solved-how-to-access-post-thumbnail-from-twig-template/651/2 "2016-07-27T10:14:22Z")

</div>

`episode.post` is the core WP\_Post object, not a “Twig-optimized” wrapper like all the other objects. Unfortunately this object is rather useless as it only enables accesss to few metadate (the most useful being `episode.post.ID`).

WordPress functions like `the_post_thumbnail` are not available to Twig by default. Some PHP code is necessary to create a Twig wrapper for them. See [https://github.com/podlove/podlove-publisher/blob/master/lib/template/twig\_filter.php#L83](https://github.com/podlove/podlove-publisher/blob/master/lib/template/twig_filter.php#L83) for example, which makes some WP checks available to Twig.

---

<div class="post-metadata">

**Author:** ![funkenstrahlen](https://community.podlove.org/user_avatar/community.podlove.org/funkenstrahlen/32/281_2.png) [@funkenstrahlen](https://community.podlove.org/u/funkenstrahlen)\
**Post date:** [July 29, 2016, 8:25am UTC](https://community.podlove.org/t/solved-how-to-access-post-thumbnail-from-twig-template/651/3 "2016-07-29T08:25:43Z")

</div>

Thanks! I will see if I am able to use this way to make the post thumbnail function available.
