diff --git a/wp-content/themes/twentyeleven/image.php b/wp-content/themes/twentyeleven/image.php index 74228dbdbf..7516b034c8 100644 --- a/wp-content/themes/twentyeleven/image.php +++ b/wp-content/themes/twentyeleven/image.php @@ -57,9 +57,10 @@ get_header(); ?> if ( $attachment->ID == $post->ID ) break; } - $k++; + // If there is more than 1 attachment in a gallery if ( count( $attachments ) > 1 ) { + $k++; if ( isset( $attachments[ $k ] ) ) // get the URL of the next image attachment $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); diff --git a/wp-content/themes/twentyten/loop-attachment.php b/wp-content/themes/twentyten/loop-attachment.php index 3976b0d6e8..26e213eec0 100644 --- a/wp-content/themes/twentyten/loop-attachment.php +++ b/wp-content/themes/twentyten/loop-attachment.php @@ -71,9 +71,10 @@ if ( $attachment->ID == $post->ID ) break; } - $k++; + // If there is more than 1 image attachment in a gallery if ( count( $attachments ) > 1 ) { + $k++; if ( isset( $attachments[ $k ] ) ) // get the URL of the next image attachment $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); diff --git a/wp-content/themes/twentytwelve/image.php b/wp-content/themes/twentytwelve/image.php index 285e453c71..1dc2aa9312 100644 --- a/wp-content/themes/twentytwelve/image.php +++ b/wp-content/themes/twentytwelve/image.php @@ -58,9 +58,9 @@ foreach ( $attachments as $k => $attachment ) : break; endforeach; -$k++; // If there is more than 1 attachment in a gallery if ( count( $attachments ) > 1 ) : + $k++; if ( isset( $attachments[ $k ] ) ) : // get the URL of the next image attachment $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );