• Hey All,

    I use a custom page template to display the images of a default wordpress gallery. It contains the following code, which gives my fancybox, title, description etc etc. The problem I’m encountering is that the order of the thumbnails on the displayed page are not the same order as the one the user made in the wordpress backend.
    Does anyone have a clue on how to add the users order to the thumbnails?

    <ul class="gallery_ul">
    		<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
    			$args = array(
    				'post_type' => 'attachment',
    				'numberposts' => -1,
    				'post_status' => null,
    				'post_parent' => $post->ID
    			);
    			$attachments = get_posts( $args );
    				if ( $attachments ) {
    				foreach ( $attachments as $attachment ) {
    					echo '<li class="gallery_li">';
    					echo '<a href="';
    					$src = wp_get_attachment_image_src( $attachment->ID, "attached-image");
    					if ($src) {echo $src[0];}
    					echo '" rel="lightbox" data-lightbox="gallery" title="<h1>';
    					echo apply_filters( 'the_title', $attachment->post_title );
    					echo '</h1>';
    					echo apply_filters( 'the_description', $attachment->post_excerpt );
    					echo '<br />';
    					echo apply_filters( 'the_caption', $attachment->post_content );
    					echo '">';
    					echo '<img src="';
    					$thumbsrc = wp_get_attachment_image_src( $attachment->ID, "grid-proportional-thumbnail");
    					if ($thumbsrc) {echo $thumbsrc[0];}
    					echo '" alt="';
    					echo apply_filters( 'the_caption', $attachment->post_excerpt );
    					echo '" />';
    					echo '</a>';
    					echo '</li>';
    					}
    				}
    		endwhile; endif; ?>
    	</ul>

    Thank you!

  • The topic ‘Use the order of the default gallery inside wordpress’ is closed to new replies.