Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

How do I get an array of categories from taxonomies

Started by Muut Archive 11 years ago · 2 replies · 532 views
11 years ago

I have the following taxonomies set up in site.yaml
taxonomies: [category,tag,month,author]

For my blog page I want to have a list of all categories that are available. I see how you can find pages assigned to a category, but how do I just loop through and get all the categories of the Category Taxonomy?

11 years ago

I figured it out. I missed the parameter set in the includes.

TWIG
{% if config.plugins.taxonomylist.enabled %}
<div class="widget">
    <h4>Categories</h4>
    {% include 'partials/categories.html.twig' with {'taxonomy':'category'} %}
</div>
{% endif %}

I just had to change {'taxonomy':'tag'} to {'taxonomy':'category'}

I must be getting too old for this stuff. So simple but I wasted a couple hours anyhow.

11 years ago

Great when you work it out yourself though isn't it :) Most satisfying!

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1349 9 years ago
Archive · by Muut Archive, 9 years ago
2 934 9 years ago
Archive · by Muut Archive, 9 years ago
2 4060 9 years ago
Archive · by Muut Archive, 9 years ago
1 2946 9 years ago
Archive · by Muut Archive, 9 years ago
3 1118 9 years ago