Home › Forums › Backend Issues (wp-admin) › One section on multiple sub-pages › Reply To: One section on multiple sub-pages
Getting the values from another post or page would be difficult, you’d need to know ahead of time what post you want the get the values from, using an options page would be easier.
In either case you would use an acf/load_field filter http://www.advancedcustomfields.com/resources/acfload_field/
add_filter('acf/load_field/name=repeater_name', 'populate_repeater');
function populate_repeater($field) {
// I'm using an options page in this example
// but you can change $other_post_id to something else
$other_post_id = 'options';
if (have_rows('repeater_name', $other_post_id)) {
$value = array();
$subfields = array(
'list',
'yours',
'subfields',
'here'
);
while (have_rows('repeater_name', $other_post_id)) {
the_row();
$row = array();
foreach ($subfields as $subfield) {
$row[$subfield] = get_sub_field($subfield);
} // end foreach subfield
$value[] = $row;
} // end while have rows
$field['value'] = $value;
} // end if have rows
return $field;
}
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.