嘗試下面的代碼,
<?php
$images = array();
while($myquery->have_posts()) :
$myquery->the_post();
$images[] = get_the_post_thumbnail_url();
endwhile;
?>
設置posts_per_page爲3 現在您的圖片在數組中。在您的Div元素中使用$ images [0],$ images [1] & $ images [2]。 在循環下面打印您的html。
更新:它非常直接。只需在您的循環下面添加以下代碼,
<div class="body1">
<div class="container bb">
<?php
$myquery = new WP_Query('category_name=body1-items&posts_per_page=3');
$images = array();
while($myquery->have_posts()) :
$myquery->the_post();
$images[] = get_the_post_thumbnail_url();
endwhile;
?>
<div class="a870">
<img class="bor-img" src="<?php echo $images[0]; ?>">
</div>
<div class="sup">
<img class="bor-img" src="<?php echo $images[1]; ?>">
<img class="bor-img smaly" src="<?php echo $images[2]; ?>">
</div>
</div>
<hr>
</div>
您的循環中沒有三個帖子。您已將'posts_per_page'設置爲1.您在while循環的單次迭代中輸出相同的發佈縮略圖3次 –
謝謝,但我有3個帖子:http://imgur.com/a/HFfXL –
當我將posts_per_page設置爲3或更多,我有3個div 3次! http://imgur.com/a/tO9BT –