3

ここに私の問題があります。

何かのスライダーと相まって、ワードプレスと魔法のフィールドで奇妙な動作が発生しています。主な問題は、スライダーに読み込もうとしているサムネイル画像がコンテンツで倍増していることです。同様に、wordpress コンテンツから読み込まれる実際の画像は、1 回ではなく 2 回読み込まれます。説明するのが難しいので、私のコードをざっと見ていただければ幸いです。ありがとうございます。

    <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>

提供できるヘルプをありがとう。

4

1 に答える 1

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>が endwhile の後にあることに注意してください。このようにループ内にあるはずです...

<?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; ?>

これで問題が解決するかどうかお知らせください。

于 2012-03-09T14:27:24.770 に答える