嗨,我的模板页面中的二次循环有问题。php。我试图显示一些证明,检索这些证明的代码在我的索引中工作得非常好。php,但如果我从模板页面调用,我不会检索任何推荐信息。这里是我的代码:幻灯片。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 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;
?>
</div>
</div>
</div>
</div>
<hr>
</div>
如果我在主循环执行之前移动include,它就会工作,我将感谢您的帮助。