How to make a loop work for a slider
-
Hi,
I’m trying to create a slider that works with the loop in wordpress. I created a post-type so my client can add new slides by creating specific posts (title and image) in the dashboard.
The html is the following:
<div class="tab-content"> <div id="marmol" class="tab-pane fade in active"> <div class="row"> <?php $loop = new WP_Query( array( 'post_type' => 'materiales', 'orderby' => 'post_id', 'order' => 'ASC' ) ); ?> <div class="col-sm-6"> <div id="carousel" class="carousel slide" data-ride="carousel"> <div class="carousel-inner big-image"> <?php while( $loop->have_posts() ) : $loop->the_post(); ?> <div class="item active"> <img src="<?php the_post_thumbnail(); ?>"> <div class="leyenda"> <p><?php the_title(); ?></p> </div> </div> </div><!-- carousel-inner big-image --> </div><!-- carousel --> <?php endwhile; ?> </div> <!-- /col-sm-6 --> <div class="col-sm-6"> <p>some text</p> </div> <!-- /col-sm-6 --> </div> <!-- /row --> </div><!-- marmol --> </div><!-- tab-content -->'
Obviously this doesn’t work. All the images are loaded instead of just loading the correct one each time
Then I have a small “thumb carousel” so the user can click the image that is loaded in the slider. But I’ve omitted it for now in order to work just in the slider.
Any idea how should I call the loop to make the slider work?
Thanks in advance
- The topic ‘How to make a loop work for a slider’ is closed to new replies.