How to show Category on post Element?

I need to achieve something like the image below showing the category on the post. When I try the meta category it’s showing all categories but I just need to show one category the parent or the first category.

Hi @wissam,

afaik you can´t control this within the posts element settings without touching the code, but you can control the output via css. Let’s say you add the post_terms_category field as a p tag, just paste this css code inside the custom css settings of the post element:

root .content-wrapper p.dynamic a {
  display: none;
}

root .content-wrapper p.dynamic a:first-of-type {
  display: inline-block;
}

/** Alternative: access via data field id

root p[data-field-id='paste-the-id-here'] a {
  display: none;
}

root p[data-field-id='paste-the-id-here'] a:first-of-type {
  display: inline-block;
}
*/

The first post in my screenshot has two Categories, but after applying the css, only the first one is showing. The only thing missing is to “remove” the comma…

Regards,
timmse

2 Likes

You’re a life saver thank you

1 Like

You´re welcome!
I just saw a really simple solution in one of your threads to remove the comma, available in Bricks 1.3.2.

Instead of using {post_terms_category} inside the dynamic data field just use {post_terms_category:} and the comma is gone.

3 Likes