WordPress.org

Ready to get started?Download WordPress

Forums

Archive Listing: Nested Duplicate DIVS (Elastislider) (1 post)

  1. WebmistressM
    Member
    Posted 7 months ago #

    I'm working with custom content types, creating a template for the "archive listing" for a particular content type under a particular category. While working with the loop, I have run into a problem with what is being output vs. what I have actually written within the loop.

    This is the code as it appears in my template file's loop:

    http://pastebin.com/9ZkkZ27S

    The main part Im concerned with is this part of the code:

    <div class="additional-images c9">
    <ul id='carousel' class='elastislide-list'>
      	  <script type="text/javascript">
        jQuery(document).ready( function() {
    jQuery('#carousel').elastislide();
    });
      </script>
    	<li><? list($thumb_src, $thumb_w, $thumb_h) = wp_get_attachment_image_src( get_custom_field('accessory_1'), 'additional-image');
    	list($full_src, $full_w, $full_h) = wp_get_attachment_image_src( get_custom_field('accessory_1'), 'full'); ?>
    	<a href="<?php print $full_src; ?>"><img class="colorbox-<?php echo $post->ID; ?>" src="<?php print $thumb_src; ?>" /></a></li>
    	<li><? list($thumb_src, $thumb_w, $thumb_h) = wp_get_attachment_image_src( get_custom_field('accessory_2'), 'additional-image');
    	list($full_src, $full_w, $full_h) = wp_get_attachment_image_src( get_custom_field('accessory_2'), 'full'); ?>
    	<a href="<?php print $full_src; ?>"><img class="colorbox-<?php echo $post->ID; ?>" src="<?php print $thumb_src; ?>" /></a></li>
    	<li><? list($thumb_src, $thumb_w, $thumb_h) = wp_get_attachment_image_src( get_custom_field('accessory_3'), 'additional-image');
    	list($full_src, $full_w, $full_h) = wp_get_attachment_image_src( get_custom_field('accessory_3'), 'full'); ?>
    	<a href="<?php print $full_src; ?>"><img class="colorbox-<?php echo $post->ID; ?>" src="<?php print $thumb_src; ?>" /></a></li>
    <?php if ((get_custom_field('accessory_4')) !== ''): ?>
    	<li><? list($thumb_src, $thumb_w, $thumb_h) = wp_get_attachment_image_src( get_custom_field('accessory_4'), 'additional-image');
    	list($full_src, $full_w, $full_h) = wp_get_attachment_image_src( get_custom_field('accessory_4'), 'full'); ?>
    	<a href="<?php print $full_src; ?>"><img class="colorbox-<?php echo $post->ID; ?>" src="<?php print $thumb_src; ?>" /></a></li><?php endif;
    if ((get_custom_field('accessory_5')) !== ''): ?>
    	<li><? list($thumb_src, $thumb_w, $thumb_h) = wp_get_attachment_image_src( get_custom_field('accessory_5'), 'additional-image');
    	list($full_src, $full_w, $full_h) = wp_get_attachment_image_src( get_custom_field('accessory_5'), 'full'); ?>
    	<a href="<?php print $full_src; ?>"><img class="colorbox-<?php echo $post->ID; ?>" src="<?php print $thumb_src; ?>" /></a></li><?php endif;
    if ((get_custom_field('accessory_6')) !== ''): ?>
    	<li><? list($thumb_src, $thumb_w, $thumb_h) = wp_get_attachment_image_src( get_custom_field('accessory_6'), 'additional-image');
    	list($full_src, $full_w, $full_h) = wp_get_attachment_image_src( get_custom_field('accessory_6'), 'full'); ?>
    	<a href="<?php print $full_src; ?>"><img class="colorbox-<?php echo $post->ID; ?>" src="<?php print $thumb_src; ?>" /></a></li><?php endif;
    	 ?>
    	</ul>
    </div>

    However, when I look at the listing page in a browser, it seems that more nested divs of the same class are being created:

    Screencap: http://picpaste.com/elastislidenesteddivproblem-UZMAAXYB.jpg

    Note that some of this code is output via Elastislide's code (Elastislide here: http://tympanus.net/Development/Elastislide/index.html). One theory I have is that Elastislide is the problem, as it seems to be the one creating these divs.

    With some testing of my category, I noticed that the amount of extra divs that get nested seem to correlate with how many entries are listed on the page. So, if I have 3 items listed in this category (and thus, showing up on this archive page), than there are 3 nested divs of class "elastislide-wrapper". Whereas if 5 items are under this category than the elastislide-wrapper duplicates (and nests) 5 times. On another page, I use Elastislide but it is for single entries, and I cannot reproduce the above problem.

    Has anyone had experience where this happened and if there is anything I can do to stop it. Or, is this a symptom that suggests Elastislide only works when there is one instance on the page (as opposed to 2 or more).

    I had looked at this plug-in which seems to be an adjustment of Elastislide into a WordPress plugin...

    http://wordpress.org/plugins/elastic-slide/

    but, like many of the sliders, it isn't quite setup for the fact that Im using custom content types (via CCTM) and that I'm wishing to place code into a template.

    Can anyone shed some light on this or possibly confirm/deny if Elastislide is just not for archive/listing pages. Might need a different method to what I am doing now.

Reply

You must log in to post.

About this Topic