I’m slightly familiar with the load_value
filter, and using it in the functions.php file. I’m using the filter now to compile a lot of data, and then pre-populate a wysiwyg field upon a form loading in the frontend.
Can I do this for a gallery too?
I would like to query the posts and find images that are attached, and then pre-populate the gallery field with these images.
thanks!
Yes, you can do this. In the load value filter for the gallery field you would return and array of attachment IDs.
Thanks John! I knew that, but your message sparked me to look from another angle!
I had this:
$value = array(array('ID' => '253'), array('ID' => '170'));
But, it should be this:
$value = array('253', '170');
Used this full function:
//IMAGES field
function load_team_summary_images( $value, $post_id, $field ){
global $allUpdatesImages;
$value = $allUpdatesImages;
return $value;
}
add_filter('acf/load_value/key=field_564900d0c98d1', 'load_team_summary_images', 10, 3);
Works perfectly. I am attaching the images (from a Gallery field) to the post, so I used get_attached_media('image', $oUpdateID);
with the post ID to get all the IDs of the attached media.