【发布时间】:2013-07-29 18:10:28
【问题描述】:
我正在使用 foreach 循环来生成一组缩略图链接。我正在使用 Wordpress,出于某种原因,我的 PHP 正在执行的地方不是我想要呈现列表的地方。所以我的问题是:我可以将 echo 语句替换为存储所有生成的 html 的内容(对于每个图像,而不仅仅是最后一个图像),并允许我在同一页面的下方生成它吗?
感谢您的帮助。到目前为止,这是我的 php:
foreach ($gallery_images as $galleryID) {
$attachment = get_post( $galleryID );
$thumb_img = wp_get_attachment_image_src( $galleryID, 'thumbnail' ); //thumbnail src
$full_img = wp_get_attachment_image_src( $galleryID, 'full' ); //full img src
echo '<a href="' . $full_img[0] . '" id="description-button-' . $gallery_images_count . '" class="thumbLink" target="_blank"><img src="' . $thumb_img[0] .'"></a>';
$gallery_images_count++;
}//end forEach
【问题讨论】:
-
而不是
echo ...$html[] = ...?