Home › Forums › Bug Reports › ACF Pro – Options pages with Repeaters not working › Reply To: ACF Pro – Options pages with Repeaters not working
If you’re trying to circumvent needing WP to load completely then you might want to take look at accessing the repeater field directly using get_option()
instead of get_field()
. To be 100% honest, I almost never use get_field()
or most of the other functions built into ACF, basically because I want everything to work should ACF be deactivated for some reason…. of course if this is more than simple fields, like images or wysiwyg editors then it can be a lot more work. Here’s an example.
// the options name used by ACF to store the repeater
$repeater = 'options_'.$your_repeater_field_name;
// array of sub field names
$subfields = array(
'field_1' => 'text',
'field_2' => 'image',
'field_3 => 'wysywig'
);
// place to put the repeater values
$values = array();
$count = intval(get_option($repeater, 0));
for ($i=0; $i<$count, $i++) {
$value[] = array();
foreach ($subfields as $subfield => $type) {
$value[$subfield] = get_option($repeater.'_'.$i.'_'.$subfield, '');
switch($type) {
case 'image':
$value[$subfield] = wp_get_attachment_image_src(intval($value[$subfield]), 'full');
break;
case 'wysiwyg':
$value[$subfield] = apply_filters('the_content', $value[$subfield]);
break;
case 'text';
default:
// do nothing;
}
} // end foreach $subfield
$values[] = $value;
} // end for $i
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!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?
— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.