php - Carousel Slider with query loop inside for featured custom post type -


so i'm trying carousel slider display 3 posts @ time through loop featured custom posts type.

this code have carousel:

<div class="container">   <div class="row">     <h2>featured posts</h2>   </div>   <div class='row'>     <div class='col-md-8'>       <div class="carousel slide media-carousel" id="media">         <div class="carousel-inner">           <div class="item  active">             <div class="row">               <div class="col-md-4">                 <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>               </div>                         <div class="col-md-4">                 <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>               </div>               <div class="col-md-4">                 <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>               </div>                     </div>           </div>           <div class="item">             <div class="row">               <div class="col-md-4">                 <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>               </div>                         <div class="col-md-4">                 <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>               </div>               <div class="col-md-4">                 <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>               </div>                     </div>           </div>           <div class="item">             <div class="row">               <div class="col-md-4">                 <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>               </div>                         <div class="col-md-4">                 <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>               </div>               <div class="col-md-4">                 <a class="thumbnail" href="#"><img alt="" src="http://placehold.it/150x150"></a>               </div>                   </div>           </div>         </div>         <a data-slide="prev" href="#media" class="left carousel-control">‹</a>         <a data-slide="next" href="#media" class="right carousel-control">›</a>       </div>                               </div>   </div> </div> 

i want display thumbnails permalink following query:

<?php     $featured = new wp_query( array(          'post_type' => 'franchisings',         'posts_per_page' => '3',         'meta_key' => 'meta-checkbox',         'meta_value' => 'yes'      ) );  if ($featured->have_posts()): while($featured->have_posts()): $featured->     the_post(); ?>          <div class="row">             <div class="col-md-3">  <?php if (has_post_thumbnail()) : ?>  <a href="<?php the_permalink(); ?>">     <?php the_post_thumbnail(); ?></a>           </div>  </div>           <?php endif; endwhile; else: endif; ?> 

i don't want use plugins, , i'm using bootstrap framework. , i'm going for, featured posts' thumbnails instead:

goal

i can featured post types display can't them inside carousel.

can out? thanks

code updated @ucheng answer

<div class="container">         <div class="row">          <h3>             <a href="#" class="btn btn-outlined btn-theme btn-lg" id="button" data-wow-delay="0.7s">franchisings em destaque</a>         </h3>         <div class='col-md-8'>       <div class="carousel slide media-carousel" id="media">         <div class="carousel-inner">           <div class="item  active">      <?php         $featured = new wp_query( array(              'post_type' => 'franchisings',             'posts_per_page' => '-1',             'meta_key' => 'meta-checkbox',             'meta_value' => 'yes'          ) );       $counter = 0;         if ( $featured->have_posts()): while( $featured->have_posts() ): $featured->the_post(); ?>                  <?php if ( $counter%3 == 0 ): ?>                  <div class="item <?php if ( $counter == 0 ): ?>active<?php endif; ?>">                     <div class="row">                 <?php endif; ?>                      <?php if ( has_post_thumbnail() ): ?>                     <div class="col-md-4">                         <a href="<?php the_permalink(); ?>">                             <?php the_post_thumbnail(array(200, 200)); ?>                             <?php $counter++; ?>                         </a>                      </div>                     <?php endif; ?>                     <?php if ( $counter%3 == 0 ):?>                     </div>                   </div><!--end item-->                 <?php endif; ?>          <?php endwhile;endif;           ?> 

you need set posts_per_page -1 posts.

<div class="container">        <div class="row">         <h2>featured posts</h2>       </div>        <div class='row'>         <div class='col-md-8'>           <div class="carousel slide media-carousel" id="media">             <div class="carousel-inner">             <?php              $featured = new wp_query( array(                  'post_type' => 'franchisings',                 'posts_per_page' => '-1',//-1 posts                 'meta_key' => 'meta-checkbox',                 'meta_value' => 'yes'              ) );                   $counter = 0;             if ( $featured->have_posts()): while( $featured->have_posts() ): $featured->the_post(); ?>                      <?php if ( $counter%3 == 0 ): ?>                      <div class="item <?php if ( $counter == 0 ): ?>active<?php endif; ?>">                         <div class="row">                     <?php endif; ?>                          <?php if ( has_post_thumbnail() ): ?>                         <div class="col-md-4">                             <a href="<?php the_permalink(); ?>">                                 <?php the_post_thumbnail(); ?>                                 <?php $counter++; ?>                             </a>                          </div>                         <?php endif; ?>                         <?php if ( $counter%3 == 0 ):?>                         </div>                       </div><!--end item-->                     <?php endif; ?>              <?php endwhile;endif;               </div><!--carousel-inner-->           </div>         </div>       </div><!--end row-->  </div> 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -