this code has worked great for a long time. I pull entries and use an IF statement around which category they are in:
{exp:channel:entries channel="resources" dynamic="on" limit="1"} {if "{categories}{category_id}{/categories}” == “44” OR “{categories}{category_id}{/categories}” == “191” } …. {/if} {if "{categories}{category_id}{/categories}” == “45”} …. {/if}
All was good until I got an entry with more than one category (84&191;). The output is {category_id} = “84191” which doesn’t get caught in my conditional.
I don’t want to use the “contains” conditional b/c then an entry with category 84 & 4 would be “844” and would match me looking for category=44. How do I solve this??
Thanks!
I know this is a super old post, but figured I’d add a reply considering I was running into a similar issue. I found that using the category_name or category_url_title with the “contains” operator works best for this because the names are unique. That way you don’t run into numbers meshing together if using the category_id.
You could use the category_description or custom category field for this as well.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.