无法让 jquery 和 flexslider 在新的 Wordpress 安装上工作

Can't get jquery and flexslider working on a new Wordpress install

我正在尝试向 wordpress child 主题页面添加一个简单的滑块,但无法正常工作。

滑块 html(header.php):

$args = array(
    'post_type' => 'slide'
  );

  // The Query
  $the_query = new WP_Query( $args );

  // The Loop
  if ( $the_query->have_posts() ) {
      echo '<div class="flexslider"><ul class="slides">';
      while ( $the_query->have_posts() ) {
          $the_query->the_post();
          //echo '<li><a href="#">' . the_post_thumbnail() . '</a>    </li>';//this was wrong
          echo '<li><a href="#">' . get_the_post_thumbnail() . '</a>    </li>';//this is right
      }
      echo '</ul></div>';
  } else {
      // no posts found
  }
  wp_reset_postdata();

脚本(functions.php)

function my_scripts() {
    wp_register_script( 'flexslider', get_stylesheet_directory_uri() . '/flexslider/jquery.flexslider.js', array( 'jquery' ), '1.0', true );
wp_register_script( 'slide', get_stylesheet_directory_uri() . '/flexslider/flexscript.js', array( 'jquery' ), '1.0', true );

if ( is_front_page() ) { 
    wp_enqueue_script( 'flexslider' );
}

}

add_action( 'wp_enqueue_scripts', 'my_scripts' );

jquery.flexislider.js是需要的js文件。 flexiscript.js 包含此代码:

jQuery(document).ready(function() {
jQuery('.flexslider').flexslider();
});

我也有 css 包含在 header

<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/flexslider/flexslider.css" type="text/css">

您没有对 flexscript.js 文件进行排队:

wp_enqueue_script('slide');