Anything slider and wordpress and magic fields

here’s my problem.

I’m getting some strange behavior on wordpress and magic fields coupled with the anything slider. The main issue is that the thumbnails images that I’m trying to load into the slider are doubling up in the content. As well, the actual images in being loaded in from the wordpress content load up twice, instead of just once. Difficult to describe, so it’s probably best if you take a gander at my code, thank you.

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

and then here’s my call script.

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

Thanks for any help that can be offered.

Related posts

Leave a Reply

1 comment

  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>
    

    I think AnythingSlider relies on a direct child <p><li><div> or anything else it can grab, and you have a little bit of a syntax error that may be causing the issue. Notice above that your </li> is after the endwhile. It should be inside the loop like this…

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

    Let me know if this fixes your issue.