Home › Forums › General Issues › Using ACF in Theme
Hey guys! I’ve been having a LOT of trouble trying to use ACF in my theme. What I’m trying to do is use the fields on category pages. Each category is the name of a company and I want different fields about the company such as when it was founded, how big it is, etc. The layout I want is below:
Founded: 1975
Founder(s): John Smith
Could anyone help me with the code I need to use?
Thanks!
Christian
Hi @Christian01
Sounds like this guide will help you out:
http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/
Thanks Elliot. So I managed to display the field on one of my category pages. But how can I make it so that the information is displayed on all of my pages and will change depending on the page? Also is there a way to display the field name as well?
Thanks, and sorry for being a total noobie about this!
Hi @Christian01
What do you mean by ‘displayed on all of my pages’?
On every template? Like in the footer?
Maybe you need to fully explain the brief
To get the field label, you will need to load the field object with the get_field_object function (please read the docs for this) to load the field.
Hi Elliot,
Sorry that was very vague of me. What I meant is that I want it displayed on all of my category pages. In other words, is there a code to display the field where I don’t have to use a particular category ID, but instead it uses the ID of whatever page is being loaded?
Thanks, and let me know if i’m still being too vague…
Christian
Let me rephrase what I want, just to be clear. I want to display custom fields on my category pages. I also want to display the field label, but ONLY when there is a value to be displayed after it, as that will not always be the case. The layout I want is displayed below:
Founded: 1984
Founder(s): Jim Smith, John Bob
I DO NOT want field labels to be displayed if I have not entered a value for the field, as will often be the case.
Thanks so much for your help!
Christian
Hi @Christian01
Did you look at the last code example on the linked documentation article?
That example shows how to dynamically find the term_id and taxonomy.
All you need to do is swap get_field to get_field_object
The topic ‘Using ACF in Theme’ 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.