I am trying to use the parameter {category_name} a css class on my site click here

on the slide show, you'll notice a green tag which says, "sport" underneath that tag is another tag labelled "energy" I am using the category name's to call out this css properties. I have noticed in inspector all the category names are appearing in the script however i only want one category name to appear.

I have applied the following code: `

            {exp:channel:categories channel="blog" style="linear" show_empty="no" }
    <div class="cat-box-tab {category_name}"></div>

what other parameters do i need to apply to only display one category name per post?

2 Answers 2


If you want to show the category a post is in, then you'll want to use the {categories} (doc link) tag instead.

{exp:channel:entries channel="blog"}

<div class="cat-box-tab {categories}{category_name}{/categories}"></div>

  • Mel you're a legend!!!
    – NewBoy
    Dec 20, 2012 at 22:44
  • 2
    You might want to consider using {category_url_title} instead of {category_name} to avoid issues with spaces in category names.
    – Anna_MediaGirl
    Dec 20, 2012 at 23:27
  • And add a space after that for when you have multiple categories assigned to an entry. (if you are very precise you could use the backspace parameter too)(e.g. {categories backspace="1"}{category_url_title} {/categories}
    – GDmac
    Jan 15, 2013 at 9:10

Specifically add limit=1 if you only want 1 category. {categories limit="1"}{category_url_title}{/categories}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.