In Twenty ten, make last gallery image link back to the first. Props iandstewart.

git-svn-id: https://develop.svn.wordpress.org/trunk@15208 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Thomas 2010-06-11 02:01:56 +00:00
parent 44517b3df8
commit 1eaf1b9d00
1 changed files with 12 additions and 4 deletions

View File

@ -68,10 +68,18 @@
break;
}
$k++;
if ( isset( $attachments[ $k ] ) )
$next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
else
$next_attachment_url = get_permalink( $post->post_parent );
// If there is more than 1 image 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 attachment, get the URL of the image
$next_attachment_url = wp_get_attachment_url();
}
?>
<p class="attachment"><a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
$attachment_size = apply_filters( 'twentyten_attachment_size', 900 );