2

I've followed How to Display an Entry's Category? to show the categories assigned to a particular channel entry.

Is there a way to specify a certain Category Group?

For example, my code looks like this:

{exp:channel:entries channel="training"}

    {categories}
        {category_name}<br>
    {/categories}

    {title}

{/exp:channel:entries}

So I have a channel called training. This contains a list of training courses, each of which is a channel entry. The above template lists the courses.

I then have two separate Category Groups assigned to my training channel. These are called Training course category (ID == 1) and Course type (ID == 2).

All I want to do in my {categories} {/categories} loop is work out whether the entry belongs to a specific Course type.

However, because each course has been assigned multiple categories (ID 1 and ID 2 Category Groups) it just outputs a list of any category that's been assigned. I understand this is expected behaviour. How can I alter the code so that it only looks for categories in Category Group 2?

ExpressionEngine version is 3.5.10

3

You can specify which group the categories tag looks at.

{categories show_group="2"}

https://docs.expressionengine.com/v2/add-ons/channel/channel_entries.html#show-group

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.