Oh boy… spot on!!
I was trying to foreach loop a single element array!!
I told beforehand… I don’t know what I’m doing (and got desperate). I’m sure there should be some more elegant way to accomplish this…
For now I’ll use this other solution (array_rand()) I’ve found here:
<?php
$array_key = array_rand($page->intros()->yaml());
$array_intros = $page->intros()->yaml();
?>
One var with the structure field as yaml and other with the random key.
Then, as you explained, just use it accessing directly:
<h1><?php echo $array_intros[$array_key]['title']; ?></h1>
Is it any better? Less expensive? Same thing?