Home › Forums › ACF PRO › Can't retrieve repeater values from options page › Reply To: Can't retrieve repeater values from options page
John, thanks for your testing.
I have checked my database and also checked if I have double field names (because I created the fields via PHP). No errors, no doubles.
To be sure, I deleted all entries from the database belonging to my options page (no worries, I’m in a testing environment).
After that, I added two new colors to my repeater and checked the database again. Everything is fine.
But I was surprised when I tried to read and print the repeater field this way
<?php
$test = get_field('MY_REPEATER', 'MY_OPTIONS_PAGE');
echo "<pre>";
print_r($test);
echo "</pre>";
?>
I only get the number 2
, the count of repeater rows.
Then I create a repeater with fields in the backend (not via PHP) and tested this. And yes, it works!!!
I exported this field groups to get the code and copy this into my functions.php to create the field groups via PHP to test if I make any mistakes on my first try.
And that’s the next surprise: Now it does not work!!!
With the above test I only get the number of the repeater rows and no array.
So it must have to do anything with registering the field groups via PHP.
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.