将Flexslider与WordPress结合使用,控制台完全没有显示任何错误,但滑块不起作用,我在遵循旧教程,可能是代码不确定。
HTML:
<head>
<script>
$(window).on('load', function() {
$('#slider').flexslider({
animation: "slide"
});
});
</script>
</head>
<body <?php body_class(); ?>>
<header class="header clear" role="banner">
<div class="navcanvas">
<div class="wrapper">
<!-- logo -->
<div class="logo">
<a href="<?php echo home_url(); ?>">
<?php the_custom_logo();?>
</a>
</div>
<!-- /logo -->
<!-- nav -->
<nav class="nav" role="navigation">
<?php html5blank_nav(); ?>
</nav>
<!-- /nav -->
</div><!-- /.wrapper -->
</div><!-- /.navcanvas -->
<div class="slider">
<ul class="slides">
<li>
<img src="http://lorempixel.com/g/920/300/" />
</li>
<li>
<img src="http://lorempixel.com/g/920/300/" />
</li>
<li>
<img src="http://lorempixel.com/g/920/300/" />
</li>
</ul>
<div>
</header> <!-- /header -->
Functions.php
function html5blank_styles()
{
wp_register_style('normalize', get_template_directory_uri() . '/normalize.css', array(), '1.0', 'all');
wp_enqueue_style('normalize'); // Enqueue it!
wp_register_style('html5blank', get_template_directory_uri() . '/style.css', array(), '1.0', 'all');
wp_enqueue_style('html5blank'); // Enqueue it!;
wp_register_style('flexslidercss', get_template_directory_uri() . '/css/flexslider.css', array(), '2.7.1', 'all');
wp_enqueue_style('flexslidercss'); //Slider css
// Load HTML5 Blank scripts (header.php)
function html5blank_header_scripts()
{
if ($GLOBALS['pagenow'] != 'wp-login.php' && !is_admin()) {
//Jquery
wp_deregister_script( 'jquery' );
// wp_enqueue_script('jquery');
wp_register_script('jquery', get_template_directory_uri() . '/js/jquery-3.3.1.min.js', array(), '4.3.0'); // Conditionizr
wp_enqueue_script('jquery'); // Enqueue it!
wp_register_script('conditionizr', get_template_directory_uri() . '/js/lib/conditionizr-4.3.0.min.js', array(), '4.3.0'); // Conditionizr
wp_enqueue_script('conditionizr'); // Enqueue it!
wp_register_script('modernizr', get_template_directory_uri() . '/js/lib/modernizr-2.7.1.min.js', array(), '2.7.1'); // Modernizr
wp_enqueue_script('modernizr'); // Enqueue it!
wp_register_script('html5blankscripts', get_template_directory_uri() . '/js/scripts.js', array('jquery'), '1.0.0'); // Custom scripts
wp_enqueue_script('html5blankscripts'); // Enqueue it!
wp_register_script('flexslider', get_template_directory_uri() . '/js/jquery.flexslider-min.js', array('jquery'), '2.7.1'); // Custom scripts
wp_enqueue_script('flexslider'); // Slider js
}
}
似乎很多人都遇到此错误。如果需要任何屏幕截图或代码,请告诉我。除非我输入一些不必要的详细信息,否则似乎stackoverflow不会让我发布。请忽略整个段落。