Working with Categories
In this video, we will add a category group and categories to our blog, as well as display them in our blog template.
What We Do
- Create a category group
- Create categories
- Assign a category group to channels
- Show category loop in our most recent posts
- Use the
backspace
parameter
Code Snippets
Adding Category Loop To Display Name
{!-- Categories --}
<p class="text-sm leading-5 font-medium text-indigo-600">
{if has_categories}
{categories backspace="2"}<a class="hover:underline" href="/blog/entry/{url_title}">{category_name}</a>, {/categories}
{/if}
</p>
{!-- End categories --}
Links
- ExpressionEngine ChannelEntries Loop: https://docs.expressionengine.com/latest/channels/entries.html
- ExpressionEngine Categories Loop: https://docs.expressionengine.com/latest/channels/categories.html
- ExpressionEngine Backspace Parameter: https://docs.expressionengine.com/latest/channels/categories.html#backspace
- See all of the site build in action in the Learn EE git repository.
Comments 0
Be the first to comment!