1

I would like to display a list of category. I can display the information inside a category like slug or title.

However, I dont know how to display a category field inside a category.

    {% for category in craft.categories.group('handle') %}
       <p> {{category.title}} </p>
       <p> {{category.title}} </p>

    {% endfor %}

enter image description here

  • What is your question? – Seth Warburton Jul 13 '17 at 8:27
  • @SethWarburton A parent category has a category field. I want to display that category field data by using the parent category . – Sky Yip Jul 13 '17 at 10:04
1

If I get you right you have a category select field inside a category. If you want to grab any field values from a category you can do it the same way as with entries. Code works almost the same.

{% for category in craft.categories.group('handle') %}
    <p> {{category.title}} </p>
    <p> {{category.title}} </p>

    {# You can access any field like you normally do inside your category #}
    {{ category.categoryField }}


    {# 
       If you want to access another loop-able
       field inside your category you can just make another loop.
       Like you're looping over entries
    #}
    {% for block in category.categoryFieldName %}
        {{ block.fieldName }}
    {% endfor %}
{% endfor %}
  • Thank a lots. that is what i need. – Sky Yip Jul 14 '17 at 2:03

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.