I have an EE category name that contains an ampersand-- i.e. "Coffee & Tea." I'm displaying this name as the header for a listing of cafes and tea houses using the {category_name} field, and I'm trying to figure out the best way to properly escape the character for output to HTML. It seems that I can actually name the category within EE as

"Coffee & Tea" 

so that it will be properly rendered, although I'm not sure if this approach is at all problematic? Ideally, I'd like for EE to handle it automatically. Any thoughts? Thanks for any insight here.


It's always been curious to me that EE doesn't automatically encode entities in category names. But this quick plugin will do the trick for you.


That would be fine and is the 'proper' way to write a literal ampersand. You shouldn't get any problems.

The {category_name} field is something variable. An arbitrary string that can change without the category id changing. Think of it like the 'human readable' identifier for the category.

For that reason if you are doing any template logic to check for particular categories you should always use the {category_id} as it is a constant and cannot (or should not) change.

  • thanks-- this is how I'm handling these characters for now...
    – nickpish
    Jan 27 '15 at 0:04

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.