我正在嘗試使用Bootstrap構建圖像滑塊/旋轉木馬。這些圖像應該從我創建的Wordpress帖子類別'Aktuell'和'Referenz'中顯示。下面的代碼適合我,當我想要顯示來自類別'Aktuell'的1個圖像和來自'Referenz'類別的3個圖像時。循環WP_Query旋轉木馬兩次
<div id="myCarousel" class="carousel slide hidden-sm hidden-xs ">
<div class="carousel-inner">
<?php
$the_query = new WP_Query(array(
'category_name' => 'Aktuell',
'posts_per_page' => 1,
));
while ($the_query->have_posts()) :
$the_query->the_post();
?>
<div class="item active">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('full'); ?>
<div class="carousel-caption">
<h3><?php the_title();?></h3>
<p><?php the_excerpt();?></p>
<h1>»</h1>
</div>
</a>
</div><!-- item active -->
<?php
endwhile;
wp_reset_postdata();
?>
<?php
$the_query = new WP_Query(array(
'category_name' => 'Referenz',
'posts_per_page' => 3,
'orderby' => 'rand'
));
while ($the_query->have_posts()) :
$the_query->the_post();
?>
<div class="item">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('slider');?>
<div class="carousel-caption">
<h3><?php the_title();?></h3>
<p><?php the_excerpt();?></p>
<h1>»</h1>
</div>
</a>
</div><!-- item -->
<?php
endwhile;
wp_reset_postdata();
?>
</div><!-- carousel-inner -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">›</a>
</div><!-- #myCarousel -->
我想要做的就是從每個類別顯示3張照片。所以當我在#6行上使用'posts_per_page' => 3,
時,當我點擊左右箭頭來滑動時,滑動功能將不再起作用。相反,圖像顯示在彼此之下。
我該如何解決這個問題?