I’m trying to pass the sub_field image url into my functions.php using wp_localize_script, then pass it over as a var in my js. I’ve successfully passed image urls using get_field onto my functions.php and then into my js but for some reason I cannot use the same technique with get_sub_field(), returns nothing. Any thoughts?
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)
Thanks for the reply. After much tinkering I figured out that I need to include the have_rows loop in the functions.php to obtain the desired sub_field data. But the issue is that when I pass that data over to my variable as an array, I get all the urls concatenated as one string. This only happens when a page has multiple rows not when there is only 1.
Since this is more of a general PHP question and not ACF specific, I’ll mark your replay as the solution.