330 Locust Dr.
Verona, WI 53593
Powderkeg Web Design
Message Us

Advanced Custom Fields Pro Tips: Calling and using fields in a template

January 10, 2017

We love Advanced Custom Fields. We use them on pretty much every Word Press project. I’d like to start sharing some tips that I find useful that have to do with the greatness that is ACF.

One thing I like to do when creating a new template file is to organize most of my PHP data towards the top and use it as needed further below.

A standard Word Press template starts life out in the simplest of forms:

If I am creating a template that uses quite a few acf fields, my next step is to call all fields associated with the page:

A lot of people call each field individually via $test = get_field(‘my_field’). While that will work, I prefer to obtain all fields with just 1 variable call. Now any fields for that post ID should be available in array form – aka:

To me, this allows you to quickly scan the top of the template file to see what data is being manipulated instead of having to hunt through a bunch of HTML. It pretty much comes down to user preference on how you want to set up your templates, but I have found this way to be the most efficient.

Lead Developer

Nick is an ambitious and versatile developer with a wide range of talents. He is an efficient coder that utilizes his resources in order to achieve both his and the clients’ goals. His Alma Mater is the University of Wisconsin – Stevens Point where he graduated with honors in Web and Digital Media Development.