Support

Account

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.