diff --git a/src/wp-content/themes/twentyfourteen/functions.php b/src/wp-content/themes/twentyfourteen/functions.php index 9b7cf0b6d8..5c07d81fe1 100644 --- a/src/wp-content/themes/twentyfourteen/functions.php +++ b/src/wp-content/themes/twentyfourteen/functions.php @@ -319,9 +319,9 @@ function twentyfourteen_the_attached_image() { // If there is more than 1 attachment in a gallery... if ( count( $attachment_ids ) > 1 ) { - foreach ( $attachment_ids as $attachment_id ) { + foreach ( $attachment_ids as $idx => $attachment_id ) { if ( $attachment_id == $post->ID ) { - $next_id = current( $attachment_ids ); + $next_id = $attachment_ids[ ( $idx + 1 ) % count( $attachment_ids ) ]; break; } } diff --git a/src/wp-content/themes/twentythirteen/functions.php b/src/wp-content/themes/twentythirteen/functions.php index e1f27ad09b..a2337b2a43 100644 --- a/src/wp-content/themes/twentythirteen/functions.php +++ b/src/wp-content/themes/twentythirteen/functions.php @@ -421,9 +421,9 @@ function twentythirteen_the_attached_image() { // If there is more than 1 attachment in a gallery... if ( count( $attachment_ids ) > 1 ) { - foreach ( $attachment_ids as $attachment_id ) { + foreach ( $attachment_ids as $idx => $attachment_id ) { if ( $attachment_id == $post->ID ) { - $next_id = current( $attachment_ids ); + $next_id = $attachment_ids[ ( $idx + 1 ) % count( $attachment_ids ) ]; break; } }