WordPress.org

Ready to get started?Download WordPress

Forums

Gallery attachments won't reorder (1 post)

  1. alessbkk
    Member
    Posted 1 year ago #

    Hi all,

    after trying different solutions it seems I can't get the new WordPress 3.5 gallery work properly.

    My problem is that whenever I create a new gallery and I link every image to the attachment page, those are in the right order when i browse them.
    As soon as I change the images order on the main gallery those are updated in the gallery post, but the attachments keep following the older sequence and won't get updated.

    I'm using this code in the attachment page:

    <?php
    	$attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order' ) ) );
    	foreach ( $attachments as $k => $attachment ) {
    		if ( $attachment->ID == $post->ID )
    			break;
    	}
    	$k++;
    	// If there is more than 1 attachment in a gallery
    	if ( count( $attachments ) > 1 ) {
    		if ( isset( $attachments[ $k ] ) )
    			// get the URL of the next image attachment
    			$next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
    		else
    			// or get the URL of the first image attachment
    			$next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
    	} else {
    		// or, if there's only 1 image, get the URL of the image
    		$next_attachment_url = wp_get_attachment_url();
    	}
    ?>

    How can sincronize the gallery order with the attachment page order?

Topic Closed

This topic has been closed to new replies.

About this Topic