Hey folks,
I tried to find it, but no luck.
Does anyone know how to bind a CSS class to a dynamic data field? I am wanting to be able to apply specific CSS styles to specific fields.
Cheers
Hey folks,
I tried to find it, but no luck.
Does anyone know how to bind a CSS class to a dynamic data field? I am wanting to be able to apply specific CSS styles to specific fields.
Cheers
Hi shingen,
welcome to the forum!
Every dynamic data field has a data-field-id. Inspect the frontend with developer tools to get the ID of the specific field.
You can target this field with something like:
.dynamic[data-field-id="687bb0"] {
color: red;
}
Best regards,
timmse
Hey Timmse,
Aww, perfect â thank you for that and the quick reply! =)
I had the same question, but wanted to add a background colour (via css) to a specific ACF field in a custom post inside a Query Loop. In other words, the posts are sessions in a conference timetable and some of the sessionsâ titles needed to be marked as âplenaryâ. The data-field-ids in this case are 0-10, and repeated on different days, so that wasnât going to work.
To begin with I thought it would work to have a true/false plenary ACF and then apply an âifâ php snippet into the class of the basic text element. That didnât work - the php wasnât being read as phpâŚ
What did work was to change the ACF field to a simple text field and add the word âplenaryâ to the session where needed. The I was able to simply add {acf_plenary_field} to the elementâs class field. Which add the correct class of plenary to the front end.