I'm setting my categories by matching the third segment to a category slug. How do I get the category title?
{% set catSlug = craft.request.getSegment(3) %}
{% set category = craft.categories.slug(catSlug) %}
{{ category.slug }} returns the slug, but {{ category.title }} returns nothing.
{{ category.slug }}
is giving you the slug, it sounds like you’ve got is actually working. Not sure why{{ category.title }}
would not be working though. What does{{ dump(category) }}
give you? (you’ll need to have dev mode enabled to use thatdump()
function.)