How to correctly use episode category in Templates?

Hi!

I’m trying to insert a translated part of the show notes into the episode page, if the episode is categorised as “English”. The if-conditional is however never found to be true.

{% if category.slug == "english" %}
    [podlove-template template="motivator"]
    {% else %}
    [podlove-template template="Motivierer"]
{% endif %}

Please let me know what’s wrong there? The Template Tags docu & Twig’s own docu didn’t already provide the answer.

I tried category.slug('english') , .name and a bunch of other variants I found on GitHub. The category is set correctly in Wordpress.

1 Like

BUMP!
It took me weeks to find the answer, but I finally figured out how to do this, so I’m sharing the knowledge, so others don’t have to struggle with the inadequate documentation on this!

{% if not is_feed() and episode.categories ({slug: “cat-slug”}) %}
{# display special web player for episodes in cat-slug category #}
{{ episode.player ({ config: “newconfig”, theme: “newtheme”, template: “default” }) }}

{% elseif not is_feed() and not episode.categories ({slug: “upcoming”}) %}
{# display default web player for episodes, except in upcoming category #}
{{ episode.player }}

{% endif %}

1 Like