I can't use shortcode with foreach. It gives me syntax error. Where i am wrong?
function create_galeri_shortcode($atts) {
$atts = shortcode_atts(
array(
),
$atts,
'galeri'
);
if ( has_post_format( 'gallery' )) {
$images = get_post_meta(get_the_ID(), 'vdw_gallery_id', true);
if($images) {
$out = '<div id="lightgallery">'.
foreach ($images as $imageid) {
$altyazi = get_post_meta( get_the_ID(), '_wp_attachment_image_alt', true ).'
<a href="'.wp_get_attachment_url($imageid, 'large').'" data-sub-html=".caption">
<img src="'.wp_get_attachment_url($imageid, 'thumbnail').'" alt="'.$altyazi.'">
<div class="caption">
<h4>'.$altyazi.'</h4><p>'.wp_get_attachment_caption($imageid).'</p>
</div>
</a>
'.}.'
</div>';
}
}
return $out;
}
add_shortcode( 'galeri_mm', 'create_galeri_shortcode' );