Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 当存在另一个查询时,为什么此查询不起作用?_Php_Wordpress_Twitter Bootstrap 3_Owl Carousel - Fatal编程技术网

Php 当存在另一个查询时,为什么此查询不起作用?

Php 当存在另一个查询时,为什么此查询不起作用?,php,wordpress,twitter-bootstrap-3,owl-carousel,Php,Wordpress,Twitter Bootstrap 3,Owl Carousel,这让我快发疯了,我肯定这是件愚蠢的事,但我太累了,找不到它。我正在构建一个自定义的WP主题,它有两个滑块,一个是默认的引导滑块,另一个是Owl滑块。在您告诉我“为什么不使用两个Owl slider实例?”之前,我已经想到了这一点,并进行了测试和工作。然而,我很好奇为什么这不起作用。这是我的密码: 引导转盘: <section id="panel4"> <div class="container"> <h2>Testimonials</h2&g

这让我快发疯了,我肯定这是件愚蠢的事,但我太累了,找不到它。我正在构建一个自定义的WP主题,它有两个滑块,一个是默认的引导滑块,另一个是Owl滑块。在您告诉我“为什么不使用两个Owl slider实例?”之前,我已经想到了这一点,并进行了测试和工作。然而,我很好奇为什么这不起作用。这是我的密码:

引导转盘:

<section id="panel4">
  <div class="container">
    <h2>Testimonials</h2>
  </div>
  <!-- container -->
  <div class="container-fluid">
    <?php $queryObject=new WP_Query( 'post_type=testimonial' ); // The Loop! if ($queryObject->have_posts()) { ?>
    <div id="carousel-testimonial" class="carousel slide" data-ride="carousel">
      <!-- Wrapper for slides -->
      <div class="carousel-inner" role="listbox">
        <?php while ($queryObject->have_posts()) {$queryObject->the_post(); ?>
        <div class="item ">
          <div class="container">
            <div class="row">
              <div class="col-sm-3 col-md-2 thumb-box">
                <img class="thumb" src="<?php echo types_render_field( " testimonial-avatar ", array( url => "true ", "width " => "400 ", "height " => "300 ", "proportional " => "true " ) );?>">
              </div>
              <div class="col-sm-9 col-md-10">
                <h3>"<?php echo types_render_field("testimonial-excerpt", array("argument1"=>"value1","argument2"=>"value2","argument2"=>"value2"));    ?>"</h3>

                <blockquote>
                  <?php echo types_render_field( "testimonial-text", array( "argument1"=>"value1","argument2"=>"value2","argument2"=>"value2")); ?></blockquote>
                <p class="sig">
                  <?php echo types_render_field( "testimonial-name", array( "argument1"=>"value1","argument2"=>"value2","argument2"=>"value2")); ?></p>
              </div>
            </div>
          </div>
        </div>
        <?php } ?>
      </div>
      <?php } ?>
      <!-- Controls -->
      <a class="left carousel-control" href="#carousel-testimonial" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
      </a>
      <a class="right carousel-control" href="#carousel-testimonial" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
      </a>

    </div>
    <!-- .carousel -->
  </div>
  <!-- .container -->
</section>

推荐书
“真”、“宽”=>“400”、“高”=>“300”、“比例”=>“真”);?>">
""

然后是猫头鹰滑块

<?php if( have_rows( 'slider_photos') ): ?>

<div class="container-fluid">
  <div id="happy" class="owl-carousel">

    <?php while( have_rows( 'slider_photos') ): the_row(); // vars $image=g et_sub_field( 'slider_image'); ?>
    <div class="item-owl">
      <img class="img-responsive" src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />
    </div>

    <?php endwhile; ?>

  </div>
  <!-- .carousel -->
</div>

<?php endif; ?>

“alt=”“/>
现在,问题似乎出在引导中。如果我把它取下来,猫头鹰滑块就会工作。如果我添加两个Owl Slider实例,它就会工作。如果我添加引导旋转木马,只有引导工作,Owl什么也不显示(即使在代码中也不显示,就好像它根本不存在一样)


有人能告诉我发生了什么以及如何解决这个问题吗?

在Owl滑块中有行('slider\u photos')之前,您很可能需要调用
wp\u reset\u postdata()
,以恢复您在引导旋转木马循环中覆盖的全局
$post
对象

有行('slider\u photos')
取决于全局
$post
对象


另一个选项是使用
have_rows('slider_photos',$post_id)
来指定要使用的
$post_id

可能是JavaScript冲突?你的浏览器控制台有什么错误吗?我想了一下,但一点错误都没有,就像它不存在一样更多信息:如果我将Owl滑块放在引导转盘之前,它也可以工作,只是不能像我现在这样工作哇,没想过,但是是的,很可能这就是原因,明天我会在办公室测试,但非常肯定这是正确答案是的,谢谢,是的,我完全忘了把它标记为正确,我的错!