Home › Forums › Backend Issues (wp-admin) › How to add a class to an element using ACF?
Hello,
I am trying to add a class name to an element using ACF but I cannot get it done… Please does anybody how to solve it?. Thank You!!!

Hey,
I tried it but it is not working… When I put the class name it doesn’t appear in class”This is empty – class name”

code here would be better, it is impossible to copy and paste text from an image
<i class="<?php the_field('home_icons', 5); ?>">
you are trying to get the values from the post ID of 5, not the current post or options. Whatever post ID 5 is probably does not have a value. Are you sure you want to specify a post ID here?
Even if I remove Post ID 5 is still the same the image doesn’t appear…
This is how it works – you put a class and the icon appear that what I am trying to get… :))
https://yadi.sk/i/68ZHjBAhzriIwQ

Please provide more information. Where is this value saved? Is it on a post or is it options? What kind of field is it? Is it a sub field of a repeater, group or flexible content field?
https://yadi.sk/i/s6s8gZeW0_ZZeg
It is saved in a Post Category that’s why I put an ID

That information would have been helpful. You need to supply the correct value so ACF know where to get the value from https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/
The topic ‘How to add a class to an element using ACF?’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.