- This topic has 4 replies, 2 voices, and was last updated 7 months, 1 week ago by .
-
Topic
-
Hi, i am trying to get the name of the current post category, and compare it to do some conditional tasks
but the condition don’t work, i think because the category is not just a slug, it’s a link !
here is my code
{% set cat = mb.get_the_term_list( post.ID, 'category') %} {{ cat }} {% if cat == archives %} <p>test</p> {% endif %}
i try to echo test when the category slug is ‘archives’
i also tried with
{% set termList = mb.get_the_terms( post.ID, 'category' ) %} {{ termList[0].slug }}
but it didn’t work either, maybe because i get a couple empty lines when it showed up in the chrome inspector !
i just need to get the category slug to compare it with simple text for some conditions
please help
thanks in advance
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.