Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.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 ACF中继器和Flexslider不工作_Php_Html_Wordpress_Advanced Custom Fields_Flexslider - Fatal编程技术网

Php ACF中继器和Flexslider不工作

Php ACF中继器和Flexslider不工作,php,html,wordpress,advanced-custom-fields,flexslider,Php,Html,Wordpress,Advanced Custom Fields,Flexslider,由于某些原因,我的图像没有显示出来,我似乎无法理解。当我检查页面时,我也会遇到这个错误,$(…)。onload不是一个函数。 下面是所有与滑块有关的代码,也许你会注意到一些错误。谢谢 <head> <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/css/flexslider.css"> <script src="https:

由于某些原因,我的图像没有显示出来,我似乎无法理解。当我检查页面时,我也会遇到这个错误,$(…)。onload不是一个函数。 下面是所有与滑块有关的代码,也许你会注意到一些错误。谢谢

<head>
  <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/css/flexslider.css">
  <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
  <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery.flexslider-min.js"></script>
  <script type="text/javascript" charset="utf-8">
    $(window).onload(function() {
      $('.flexslider').flexslider({
        animation: "slide"
      });
    });

  </script>
</head>

<div class="conatainer-fluid">
  <div class="row">
    <div class="col-md-12">
      <?php if(get_field('slider')): ?>
        <div class="flexslider">
          <ul class="slides">
            <?php while(has_sub_field('slider')): ?>
              <li><img class="img-responsive" src="<?php the_sub_field('image'); ?>" alt="Welcome to StairWorld" /></li>
              <?php endwhile; ?>
          </ul>
        </div>
        <?php endif; ?>
    </div>
  </div>
</div>


我建议你看看

这是一个很好的教程,你如何建立这个

<?php 

$images = get_field('gallery');

if( $images ): ?>
    <div id="slider" class="flexslider">
        <ul class="slides">
        <?php foreach( $images as $image ): ?>
            <li>
                <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
                <p><?php echo $image['caption']; ?></p>
            </li>
        <?php endforeach; ?>
    </ul>
</div>
<div id="carousel" class="flexslider">
    <ul class="slides">
        <?php foreach( $images as $image ): ?>
            <li>
                <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
            </li>
        <?php endforeach; ?>
    </ul>
</div>

  • “alt=”“/>

  • “alt=”“/>
请不要忘记下载并连接flexslider文件。


此外,在标题中包括以下内容:

<!-- Place in the <head>, after the three links -->
<script type="text/javascript" charset="utf-8">
  $(window).load(function() {
    $('.flexslider').flexslider();
  });
</script>

$(窗口)。加载(函数(){
$('.flexslider').flexslider();
});

我发现我必须更改$(窗口)。onload为$(文档)。ready

flexslider是否可以与jquery 3一起使用-它非常旧,因此可能只能与早期版本的jQueryA一起使用根据woocommerce网站,它与最新的jQuerywhile循环兼容?请看下面我的答案。你确定吗?它只是说1.3+(但已经很长时间没有更新),所有的例子都使用jQuery1。另外,我知道jQuery3已经删除了很多东西,因为对旧浏览器的支持已经被取消dropped@pete我更新了答案并从链接复制了代码!这不应该有什么区别-我使用了很多FlexSlider,并在窗口加载功能中启动了它们,但是如果它对你有效,那就很奇怪了
<!-- Place in the <head>, after the three links -->
<script type="text/javascript" charset="utf-8">
  $(window).load(function() {
    $('.flexslider').flexslider();
  });
</script>