Add category as a class to post wrapper

Hello there,

I am loading some posts divided by two categories: past and current.

How do I insert the category into each post wrapper in the grid? We would like to alternate the header background colour depending on the category. I can see they are wrapped with an href so can it be added to this?

The full layout is here: https://leslieh24.sg-host.com/developments/

Thanks!

Spencer

Hi Spencer,

Thanks for reaching out.
It is not very clear what exactly you are trying to achieve here. If you want to add a Class based on the Category to the Wrapper element, you can do that by adding the Dynamic Content tag to get the category name and add it to the Customize > Class as shown in the given screenshot.
If that is not the case and you are trying to point out something else, please provide a few more screenshots explaining what you are trying or any video that helps us to recognize that.

Thanks

Hi @tristup,

Thanks for getting back to me. Please see the the first image. I would like to add the category name as a class so I can customise some of their visual elements depending on the category. We only have two categories. See the second image.


Thanks,

Spencer

Hello Spencer,

Use the {{dc:post:classes}} dynamic content in the Class field. It should return the post classes including the category class. For example:
Screenshot 2024-09-12 at 12.26.36 PM

Hope this helps.

Hi @ruenel,

Thanks for this - I did not know this dynamic feature existed. Extremely useful!

:slight_smile:

Spencer

Hi Spencer,

Glad that we are able to help you.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.