Home › Forums › ACF PRO › get_fields vs multiple get_field › Reply To: get_fields vs multiple get_field
For me it would depend on what I was returning in the AJAX call. If I was returning a JSON object then I would probably use get_fields() because I’d be doing all of the formatting of the data using JavaScript after the response was returned. If I was returning HTML then I’d go back to my original comment.
If you’re worried about how many DB calls are made for the requests then you could do both, forcing ACF to get all the fields and then getting each one separately. Once the fields are loaded once they values are stored in the WP cache so later calls to get the same field will not generate another DB call.
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.