我正在尝试将以下代码显示的拇指限制为滑块中的前6项,但我无法使其工作。有谁知道怎么做我想要的东西吗?
<ul class="pictures-2">
<?php
foreach( $properties_images as $prop_image_id=>$prop_image_meta ){
$slider_thumb = wp_get_attachment_image_src($prop_image_id,'property-thumb-image');
echo '<li>';
echo '<img src="'.$slider_thumb[0].'" alt="'.$prop_image_meta['title'].'" />';
echo '</li>';
}
?>
</ul>
答案 0 :(得分:1)
<ul class="pictures-2">
<?php
$i=0;
foreach( $properties_images as $prop_image_id=>$prop_image_meta ){
$i++;
if ($i <= 6) {
$slider_thumb = wp_get_attachment_image_src($prop_image_id,'property-thumb-image');
echo '<li>';
echo '<img src="'.$slider_thumb[0].'" alt="'.$prop_image_meta['title'].'" />';
echo '</li>';
} else {
//Do Nothing
}
}
?>
</ul>