2014-09-28 87 views

回答

0

像這樣:

<div id="myCarousel" class="carousel slide"> 
    <div class="carousel-inner"> 
<?php 
    $i = 0; 
    $the_query = new WP_Query(array(
     'post__in' => get_option('sticky_posts'), 
     'ignore_sticky_posts' => 1, 
     'posts_per_page' => 7 
    )); 
    while ($the_query->have_posts()) : $the_query->the_post(); 
    $i++; 
?> 
    <div class="item <?php if($i == 1) { echo 'active'; }?>"> 
     <?php the_post_thumbnail('large');?> 
      <div class="carousel-caption"> 
       <h4><?php the_title();?></h4> 
        <p><?php the_excerpt();?></p> 
      </div> 
    </div><!-- item active --> 
<?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 -->