1
Hello, I’m trying to adjust my Carousel so that it has a grid done by loop, I have the following wordpress code:
<?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>
Works normally with wordpress post type loop, but I’m now trying to do the same, only with a grid of col-Md-3 for example, with loop leaving 4 posts starting, and then go for four more. And I’m not getting a loop out of it at all, I don’t know where I’m going wrong, I know that no loop is easy to make.
I did something on top of it, but I’m sinning on 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();
?>
Someone can help me?
How so, a grid of col-Md-3 for example, with loop leaving 4 start posts, and then go for four more. Like, you want me to press 4 posts once to stay in Carousel, and then when you do one refresh of the page, are 4 posts different?
– brazilianldsjaguar
In fact, I want to appear more than 1 post at once in Carousel, like this one: http://bootsnipp.com/snippets/featured/infinite-carousel-loop but I don’t know how to loop this way, only with 1 image at a time
– Rubens Junior
Ahh, now I get it. Your problem then lies in the fact that you can’t make more than one photo/post appear at a time?
– brazilianldsjaguar
Exactly, that’s what I need to do
– Rubens Junior
And I suppose you already have the right CSS and JS? The problem is simply not showing more than one? If you can, post Javascript (the
$('#mycarousel').carousel()
) and associated CSS (not bootstrap)– brazilianldsjaguar
I’m using the bootstrap pattern, the code I posted is pure, I made a post type only, works cool 1 at a time, a standard slide.. Only now I want to mount a slide like this, that appears more than one post at a time, da para usar o grid do bootstrap, but when it makes the loop is more complicated and I’m getting stuck
– Rubens Junior
As I mentioned in my reply, see if you can capture some images from your site (or even a link if you can, to see "personally").
– brazilianldsjaguar