<p>You can access a category's fields exactly like you
access an entry's fields.</p>

<pre><code>{{ category.myLightswitch }}
</code></pre>

<p>So this should do it for your categories loop:</p>

<pre><code>{% for entry in entries %}
    {% for category in entry.myCategoriesField %}

        {{ category }}

        {% if category.myLightswitch %}
            EXTRA
        {% endif %}

    {% endfor %}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2015-10-22T16:02:40.723Z
2015-10-22T16:02:40.723Z
carlcs
<p>I have set up a custom field for a category group. How do I get the value of this field in a loop that goes through entries? Each category in the group could have this field's value set as true or false (light switch). I.e. I need to see what category is related to the current entry and then look up the value of this field - there is some html I want to show only if the value is true.</p>

<categories>
Fields associated with a category group
# Fields associated with a category group

(Asked by: username_0 on 2015-10-22)

I have set up a custom field for a category group. How do I get the value of this field in a loop that goes through entries? Each category in the group could have this field's value set as true or false (light switch). I.e. I need to see what category is related to the current entry and then look up the value of this field - there is some html I want to show only if the value is true.

**Tags:** categories

---

## 1 answers

### Answer by username_1 on 2015-10-22. Score: 2 | Accepted answer

You can access a category's fields exactly like you
access an entry's fields.
{{ category.myLightswitch }}

So this should do it for your categories loop:
{% for entry in entries %}
    {% for category in entry.myCategoriesField %}

        {{ category }}

        {% if category.myLightswitch %}
            EXTRA
        {% endif %}

    {% endfor %}
{% endfor %}


---

