I’m working on a site for an arts organisation where we need list profiles, each including a main image and gallery of images.
Using ACF (and ACF Pro), I’ve added additional fields to user’s profiles, and want to be able to show all profiles matching particular criteria. The main image is added as an ACF image and the gallery is an ACF gallery.
There are lots of fields to show, but in essence I am showing them by going:
`<?php
$allusers = get_users(array(
‘orderby’ => ‘last_name’,
‘order’ => ‘ASC’
));
?>
<?php foreach ( $allusers as $user ) {
$usermeta = get_user_meta ($user->ID);
?>
<div class=FirstName>First name: <?php echo $usermeta[‘first_name’][0]; ?></div>
<div class=LastName>Last name: <?php echo $usermeta[‘last_name’][0]; ?></div>
<?php if (isset($usermeta[‘main_image’])){
$image_url = wp_get_attachment_image_src( $usermeta[‘main_image’][0] , ‘thumbnail’ )[0];
?>
<div class=MainImage><img src=”<?php echo $image_url ?>” /></div>
galler<?php } ?>
<?php } ?>`
But I can’t see a way to get the individual images in the gallery. When I try to go print_r($usermeta) it includes the following (for a gallery with four images):
[gallery] => Array ( [0] => a:4:{i:0;s:3:”540″;i:1;s:3:”264″;i:2;s:3:”266″;i:3;s:3:”543″;} )
What I am hoping is that it will be possible to get an array of URLs for the images in the gallery. This would be my ideal, but is there any way to access these images from PHP (so I can insert them in a web page)