duanmei2459 2014-02-04 01:21
浏览 30

使用滑块javascript时遇到问题

I'm using the flexslider for my Wordpress theme but no matter what I do, the slider doesn't appear on my website.

This is the instruction guide in using flexslider http://www.woothemes.com/flexslider/

I have added jquery.flexslider.js file inside the js folder and flexslider.css inside the css folder.

I've just followed the instruction, but I don't get the slides. All I get is a small stretched empty rectangle.

Inside the head: header.php

<script type="text/javascript" charset="utf-8">
  $(window).load(function() {
    $('.flexslider').flexslider();
    });
</script>

div with class flexslider and unordered list:

<div id="featured" class="clearfix flexslider">
        <ul class="slides">
            <?php

                $args = array(
                        'post_type' => 'work'
                    );
                $the_query = new WP_Query($args);
            ?>

            <?php if (have_posts()) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
            <li style="background-color: <?php the_field('background_color'); ?>">
                <div class="container">
                    <div class="grid_8">
                        <img src="<?php the_field( 'homepage_slider_image'); ?>" alt = "<?php the_title();?> Project Screenshot">
                    </div>

                    <div id="featured-info" class="grid_4 omega">
                        <h5>Featured Project</h5>
                        <h3 style="color: <?php the_field('button_color'); ?>">
                            <?php the_title(); ?>
                        </h3>
                        <p><?php the_field('description'); ?></p>
                        <a class="btn" style="background-color: <?php the_field('button_color'); ?>" href="#">View Project &rarr;</a>
                    </div>
                </div>
            </li>
            <?php endwhile; endif; ?>
        </ul>

    </div>

========================UPDATE==============================

Full header.php

<!DOCTYPE html>
<html>
    <head>
        <title>
            <?php
                wp_title('|', true, 'right');

                bloginfo('name')
            ?>
        </title>
        <meta name="viewport" content="width=device-width, initial-scale = 1.0">

        <?php wp_head(); ?> 

        <link rel="stylesheet" href="css/flexslider.css" type="text/css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
        <script src="js/jquery.flexslider.js"></script>

        <script type="text/javascript" charset="utf-8">
          $(window).load(function() {
            $('.flexslider').flexslider();
            });
        </script>

    </head>
    <body>

        <div class="container clearfix">
            <header>
                <div class="grid_12 omega none">
                    <hgroup>
                        <h1><a href="index.html"><?php bloginfo( 'name' ); ?></a></h1>
                        <h2><?php bloginfo( 'description' ); ?></h2>
                    </hgroup>
                </div>
                <div class="grid_12 omega">
                    <nav>


                    <?php

                        $args = array(
                            'menu' => 'main-menu'
                        );

                        wp_nav_menu($args);
                    ?>
                    </nav>
                </div>
            </header>

Full front-page.php:

<?php get_header(); ?> 
    </div>
    <div id="featured" class="clearfix flexslider">
        <ul class="slides">
            <?php

                $args = array(
                        'post_type' => 'work'
                    );
                $the_query = new WP_Query($args);
            ?>

            <?php if (have_posts()) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
            <li style="background-color: <?php the_field('background_color'); ?>">
                <div class="container">
                    <div class="grid_8">
                        <img src="<?php the_field( 'homepage_slider_image'); ?>" alt = "<?php the_title();?> Project Screenshot">
                    </div>

                    <div id="featured-info" class="grid_4 omega">
                        <h5>Featured Project</h5>
                        <h3 style="color: <?php the_field('button_color'); ?>">
                            <?php the_title(); ?>
                        </h3>
                        <p><?php the_field('description'); ?></p>
                        <a class="btn" style="background-color: <?php the_field('button_color'); ?>" href="#">View Project &rarr;</a>
                    </div>
                </div>
            </li>
            <?php endwhile; endif; ?>
        </ul>

    </div>

    <div class="container clearfix">
        <div class="grid_12 omega">
            <h5>Featured Post</h5>
        </div>

        <?php

        $args = array(
                'post_type' => 'post',
                'category_name' => 'featured',
                'posts_per_page' => 1

            );
        $the_query = new WP_Query($args);
        ?>

        <?php if (have_posts()) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>


        <div class="push_2 grid_10 omega clearfix">
            <article>

                <?php get_template_part( 'content', 'post'); ?>

            </article>
        </div>

        <?php endwhile; endif; ?>

        <div class="grid_12 omega clearfix">
            <div class="grid_6 recent-post">
                <article>
                    <h5>Recent Post</h5>

                    <?php

                    $args = array(
                            'post_type' => 'post',
                            'cat' => -6,
                            'posts_per_page' => 1

                        );
                    $the_query = new WP_Query($args);
                    ?>

                    <?php if (have_posts()) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
                        <?php get_template_part('content', 'post'); ?>

                    <?php endwhile; endif; ?>

                </article>
            </div>

                <?php

                    $args = array(
                            'post_type' => 'work',
                            'posts_per_page' => 1
                        );
                    $the_query = new WP_Query($args);
                ?>

                <?php if (have_posts()) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

                    <?php get_template_part( 'content', 'work'); ?>

                <?php endwhile; endif; ?>
        </div>
    </div>




<?php get_template_part( 'content', 'testimonials'); ?>

<?php get_footer(); ?> 
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)
    • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。