需要输出才能显示所有图像

时间:2017-02-05 10:13:41

标签: php wordpress

我有这个代码,我试图显示附加到视觉作曲家的自定义“attach_images”元素类型的所有三个图像,其中包含参数“ macimgs ”。问题是只显示最后一个图像,如果我检查保存图像的容器,我只看到一个图像而不是三个。

在这里修改什么的想法?

$gallery = shortcode_atts(
array(
    'macimgs'      =>  'macimgs',
), $atts );

$image_ids=explode(',',$gallery['macimgs']);

$image_no = 1;
foreach( $image_ids as $image_id ){
$images = wp_get_attachment_image_src( $image_id, 'full' );
$output ='
<img src="'. $images[0] .'" alt="" />
';
$image_no++;
}
return $output;

}

1 个答案:

答案 0 :(得分:2)

我认为您忘记连接$ output变量。 试试这段代码

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="collapse3">
<ol>
<button class="target1" type="button" onclick="setURL('imgs/projects/FAB/F01-Fabrication/1.html')">F01-Fabrication-1</button><br>
                        
<button class="target2" type="button" onclick="setURL('imgs/projects/FAB/F01-Fabrication/2.html')">F01-Fabrication-2</button><br>
                        
<button class="target3" type="button" onclick="setURL('imgs/projects/FAB/F01-Fabrication/3.html')">F01-Fabrication-3</button><br>
                        
<a class="target4" type="button" onclick="setURL('imgs/projects/FAB/F01-Fabrication/4.html')">F01-Fbuttonbrication-4</button><br>
                        
<button class="target5" type="button" onclick="setURL('imgs/projects/FAB/F01-Fabrication/5.html')">F01-Fabrication-5</button><br>
 </ol>
</div>