I retrieve a post via REST API as per the following:
$response = wp_remote_get(get_home_url()."2/wp-json/wp/v2/posts?include=".$postId);
$data = json_decode($response['body'], true);
Then I have:
'acf' =>
array (
'descrizione_lavoro' => '
Lorem ipsum dolor
',
'location' =>
array (
'lat' => '41.36256133817761',
'lng' => '2.131976960327165',
),
'categories' =>
array (
0 => 627,
),
'partner' =>
array (
0 => 'Sandra Yannis',
),
'collaboratori' =>
array (
0 => 'Fran White',
1 => 'Sam Jumper',
),
'importo' => '1200000',
'galleria' =>
array (
0 =>
array (
'ID' => 128345,
'id' => 128345,
'title' => 'villa1',
'filename' => 'villa1.jpg',
'filesize' => 78350,
'url' => 'http://example.com/ing2/wp-content/uploads/2019/03/villa1.jpg',
And I need to get url
so I do:
var_dump($data[0]['acf']["galleria"][0]['url']);
And works fine, but I have more than one index under galleria
therefore if I do:
var_dump($data[0]['acf']["galleria"][1]['url']);
I will get the second image but there could be plenty, how would I loop in order to retrieve all images??