0

I'm hoping someone can put me in the right direction of how I can achieve this. I know that ACF repeaters can be populated with default values like so.

function my_acf_load_value($value, $post_id, $field) {
if ($value !== NULL) {
// if the value is exactly NULL it means
// the field has never been updated
// we don't want to change fields that have already been editied
return $value;
}
// set the new field value
$value = array(
// add a nested array for each row
array(
  // add an array item for each sub field
  'field_name_1' => 'Value for Field 1',
  'field_name_2' => 'Value for Field 2'
  )
  );
  return $value;
}

What I wan't to achieve is get all pages by the current user and input these into sub fields AND sub-sub fields matching the site structure and hierarchy of pages (taking on board parents and grandparents etc)

So for example if the page structure we're like this:

Page 1
- Page 2
 - Page 3
 - Page 4
 - Page 5
Page 6
- Page 7
 - Page 8
 - Page 9
 - Page 10

I'm hoping to work with the acf_load_value function, any starting points or tips of how I can achieve this would be great.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.