1

I have to make a shortcode with acf repeater fields. I have to put the name, function of the person and a picture. The shortcode works for the name and function of the person. But I can't get the image to work here is my code:

function elus_crew($atts){
    ob_start();
        $team = get_field('les_elus', 'option');
        if ($team){
            foreach ($team as $crew):
                $image_team = $row['photo_de_lelu'];
                echo wp_get_attachment_image($image_team);
                echo '<h2>' . $crew ['prenom_nom_elu'] . '</h2>';
                echo '<span>' . $crew ['fonction_elu'] . '</span>';
            endforeach;

    $short_list = ob_get_clean();;
    return $short_list;
   }
}
add_shortcode('team_vigneaux', 'elus_crew');
Thica
  • 17
  • 2

1 Answers1

0

Try changing $row to $crew on line 6:

This:

$image_team = $row['photo_de_lelu'];

Should be:

$image_team = $crew['photo_de_lelu'];

Also note that wp_get_attachment_image() needs attachment ID, so make sure your ACF image field is configured to return Image ID

Hillel
  • 811
  • 2
  • 7
  • 19