<?php
global $posts;
$b = 0;
$args = array( 'post_type' => 'banner', 'posts_per_page' => 5 );
$loop = new WP_Query( $args );
?>
<div id="carousel-front-page" data-ride="carousel" class="carousel slide">
<div class="carousel-inner">
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="item <?php if (0 == $b) {echo "active";} ?>">
<?php the_content() ?>
</div>
<?php $b++ ?>
<?php endwhile ?>
</div>
<a class="left carousel-control" href="#carousel-front-page" data-slide="prev">
<span class="icon-prev"></span>
</a>
<a class="right carousel-control" href="#carousel-front-page" data-slide="next">
<span class="icon-next"></span>
</a>
</div>
It works normally with wordpress post type loop, but I'm now trying to do the same thing, only with a col-md-3 grid for example, with loop leaving 4 start posts, and then go for more four. And I can not really do a loop in this, I do not know where I'm going wrong, I know that without a loop it's easy to do.
I did something about it, but I'm sinning at something:
<?php
$per_page = 5;
$n=0;
$args = array( 'post_type' => 'meusprodutos', 'posts_per_page' => $per_page );
$loop = new WP_Query( $args );
if($loop->have_posts()):
?>
<div class="carousel-loja">
<div id="shopCarousel" class="carousel slide">
<div class="ponteiros">
<ol class="carousel-indicators">
<?php while($loop->have_posts()): $loop->the_post(); ?>
<li data-target="#shopCarousel" data-slide-to="<?php echo $n++; ?>"></li>
<?php endwhile; ?>
</ol>
</div><!--ponteiros-->
<!-- Carousel items -->
<div class="carousel-inner">
<div class="row">
<?php while($loop->have_posts()): $loop->the_post(); ?>
<div class="col-md-4">
<div class="item <?php if (0 == $n) {echo "active";} ?>">
<h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h4>
</div><?php $n++ ?>
</div>
<?php endwhile; ?>
</div>
</div>
</div>
</div>
<?php
endif;
wp_reset_query();
?>
Can anyone help me?