ACF中继器和Flexslider无法正常工作

时间:2017-05-05 08:51:33

标签: 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://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>

1 个答案:

答案 0 :(得分:0)

我想出来我必须将$(窗口).onload更改为$(文档).ready