WordPress.org

Make WordPress Core

Changeset 15208


Ignore:
Timestamp:
06/11/10 02:01:56 (5 years ago)
Author:
iammattthomas
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentyten/attachment.php

    r14936 r15208  
    6969    } 
    7070    $k++; 
    71     if ( isset( $attachments[ $k ] ) ) 
    72         $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); 
    73     else 
    74         $next_attachment_url = get_permalink( $post->post_parent ); 
     71    // If there is more than 1 image attachment in a gallery 
     72    if ( count( $attachments ) > 1 ) { 
     73        if ( isset( $attachments[ $k ] ) ) 
     74            // get the URL of the next image attachment 
     75            $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); 
     76        else 
     77            // or get the URL of the first image attachment 
     78            $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID ); 
     79    } else { 
     80        // or, if there's only 1 image attachment, get the URL of the image 
     81        $next_attachment_url = wp_get_attachment_url(); 
     82    } 
    7583?> 
    7684                        <p class="attachment"><a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php 
Note: See TracChangeset for help on using the changeset viewer.