Home › Forums › Front-end Issues › Passing get_sub_field() to JS script › Reply To: Passing get_sub_field() to JS script
In functions.php you need to supply the post ID to get the values from and you also need a have_rows() loop to get the sub field. Basically you need all the looping you have in the page with the addition of the post ID to get values from, this is the second optional parameter in most ACF functions like get_field('my_field', $post_id)
and have_rows('my_field', $post_id)
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.