Secondary loop doesn't work
-
Hi I got a problem with my secondary loop in my template page.php.
I’m trying to display some testimonials, the code that retrieve those testimonials works perfectly fine in my index.php but I won’t retrieve any testimonial if I make the call from my template page here is my code:
slideshow.php<div class="jumbotron bg-black"> <div class="row"> <div class="container experience"> <hr> <h2><strong>EXPERIENCIA</strong></h2> <hr style="width:300px;"> <div id="myCarousel2" style="height:250px;" class="carousel slide" data-ride="carousel"> <!-- Indicators --> <ol class="carousel-indicators"> <?php $query = new WP_Query(array( 'post_type' => 'testimonial','p' => $id, 'order' => 'ASC', 'showposts' => '11')); $i = 0; if($query->have_posts()): while($query->have_posts()) : $query->the_post(); if($i == 0) { ?> <li data-target="#myCarousel2" data-slide-to="<?php echo $i;?>" class="active"></li> <?php }else { ?> <li data-target="#myCarousel2" data-slide-to="<?php echo $i;?>"></li> <?php } $i++; endwhile; else: ?> <p><?php _e( 'Oh God Why?' ); ?></p> <?php endif; ?> </ol> <!-- Wrapper for slides --> <div class="carousel-inner" > <?php $j = 0; if($query->have_posts()): while($query->have_posts()) : $query->the_post(); if($use_excerpt){ $testimonial['content'] = get_the_excerpt(); } else { $testimonial['content'] = get_the_content(); } if($j == 0) { ?> <div class="item active" style="height:250px; width:800px;"> <?php }else { ?> <div class="item" style="height:250px; width:800px;"> <?php } ?> <div class="carousel-caption" style="width:800px;"> <p> <?php echo $testimonial['content']; ?></p> </div> </div> <?php $j++; endwhile; endif; wp_reset_postdata(); ?> </div> </div> </div> </div> </div> </div>
And here is my code of my template page:
<?php /* Template Name: Nosotros */ get_header(); ?> <div class="jumbotron-2"> <div class="row"> <div class="banner"> <img src="<?php bloginfo('template_url')?>/img/banner/empresa.jpg" class="img-responsive" alt=""> </div> </div> </div> <div class="container"> <div class="row"> <div class="col-lg-12"> <div class="row"> <div class="icon-b"><img src="<?php bloginfo('template_url')?>/img/icon-b.png" class="img-responsive" alt=""></div> <h2 style="text-align:center;"><strong><?php the_title(); ?></strong></h2> <hr> <div class="col-lg-4 col-md-4 col-ms-4"><br><img src="<?php bloginfo('template_url')?>/img/empresa.jpg" class="img-circle" alt="Empresa PERCHISA Perforaciones en Chihuahua SA de CV"></div> <div class="col-lg-8 col-md-8 col-ms-8"> <?php if (have_posts()) : while (have_posts()) : the_post(); the_content(); endwhile; else: ?> <h1>No se encontraron articulos</h1> <?php endif; rewind_posts(); ?> </div> </div> </div> </div> <hr> </div> <!-- EXPERIENCES --> <?php include(TEMPLATEPATH. '/slideshow.php'); ?> <!-- END / EXPERIENCES --> <?php get_footer(); ?>
If I move the include before the main loop is executed it works, I will apreciate your help.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Secondary loop doesn't work’ is closed to new replies.