Home › Forums › General Issues › Display Options Page repeater field in header.php › Reply To: Display Options Page repeater field in header.php
You are attempting to get the index value of a string here. To explain:
The following code results in an array:
$rows = get_field(‘location’, ‘option’);
Then you are using the 0 index to get the first value of that array, which will result in yet another array, only this time associative:
$first_row = $rows[0]
Finally, you are able to target the actual field you are looking for by it’s field label, in this case ‘location_phone’:
$first_row_phone = $first_row[‘location_phone’ ];
What results from that line of code is the string value you are looking for. By echoing out echo $first_row_phone[0];
you are confusing PHP into trying to get the index value of a string. So really, all you need to do is echo the string itself: echo $first_row_phone;
Long story short, remove the ‘[0]’ from the echo.
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.