Support » Fixing WordPress » Gallery attachments won't reorder

  • alessbkk


    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:

    	$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 )
    	// 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 );
    			// 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?

  • The topic ‘Gallery attachments won't reorder’ is closed to new replies.