任何滑块和wordpress和魔术领域

时间:2011-12-16 20:14:24

标签: jquery wordpress anythingslider

这是我的问题。

我在wordpress和魔术领域加上任何滑块都会遇到一些奇怪的行为。主要问题是我正在尝试加载到滑块中的缩略图图像在内容中加倍。同样,从wordpress内容加载的实际图像加载两次,而不是只加载一次。很难描述,所以如果你对我的代码有所了解,那可能是最好的,谢谢。

    <div class="posts">
        <div class="slider" id="slider1">
        <?php 
            $loop = new WP_Query(array('post_type' => 'printcontent', 'posts_per_page' => 50)); 
        ?>
        <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
        <li>
            <?php the_content();?>
            <h1 class="caption1"><?php echo get('print_caption'); ?></h1>
            <div class="thumbnail1"><?php echo get_image('print_thumbnail'); ?></div>
        <?php endwhile; ?>
        </li>
        </div>
        <div class="current-caption1"></div>
    </div>

然后这是我的通话脚本。

<script>
var updateCaption1 = function(slider1){
    var cap = slider1.$currentPage.find('.caption1').html();
    $('.current-caption1')
        .html(cap)
        .fadeIn(200);
};

$('#slider1').anythingSlider({

      navigationFormatter : function(i, panel){
        return panel.find('.thumbnail1').html();
      },

    // *********** Callbacks ***********
    // Callback when the plugin finished initializing
    onInitialized: function(e, slider1) { updateCaption1(slider1); },

    // Callback before slide animates
    onSlideBegin: function(e, slider1) {
        $('.current-caption1').fadeOut(200);
    },

    // Callback when slide completes - no event variable!
    onSlideComplete: function(slider1) { updateCaption1(slider1); }

});
</script>

感谢您提供任何帮助。

1 个答案:

答案 0 :(得分:1)

<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
        <li>
            <?php the_content();?>
            <h1 class="caption1"><?php echo get('print_caption'); ?></h1>
            <div class="thumbnail1"><?php echo get_image('print_thumbnail'); ?></div>
<?php endwhile; ?>
</li>

我认为AnythingSlider依赖于直接子<p><li><div>或其他任何可以获取的东西,并且您可能会遇到一些语法错误,这可能会导致问题。请注意,您的</li>是在结束之后。它应该在这样的循环内......

<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
        <li>
            <?php the_content();?>
            <h1 class="caption1"><?php echo get('print_caption'); ?></h1>
            <div class="thumbnail1"><?php echo get_image('print_thumbnail'); ?></div>
        </li>
<?php endwhile; ?>

如果这可以解决您的问题,请告诉我。