Make WordPress Core


Ignore:
Timestamp:
09/27/2012 07:01:16 AM (13 years ago)
Author:
nacin
Message:

Add tag.php and category.php to Twenty Twelve. While by no means required, it pulls some extra logic out of archive.php, instead leveraging the template hierarchy so it is hopefully more understandable to users tweaking their themes. Use alternative control structure syntax in all templates. fixes #21951.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentytwelve/image.php

    r21634 r22048  
    22/**
    33 * The template for displaying image attachments.
     4 *
     5 * Learn more: http://codex.wordpress.org/Template_Hierarchy
    46 *
    57 * @package WordPress
     
    5254 */
    5355$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 ID' ) ) );
    54 foreach ( $attachments as $k => $attachment ) {
     56foreach ( $attachments as $k => $attachment ) :
    5557    if ( $attachment->ID == $post->ID )
    5658        break;
    57 }
     59endforeach;
     60
    5861$k++;
    5962// If there is more than 1 attachment in a gallery
    60 if ( count( $attachments ) > 1 ) {
    61     if ( isset( $attachments[ $k ] ) )
     63if ( count( $attachments ) > 1 ) :
     64    if ( isset( $attachments[ $k ] ) ) :
    6265        // get the URL of the next image attachment
    6366        $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
    64     else
     67    else :
    6568        // or get the URL of the first image attachment
    6669        $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
    67 } else {
     70    endif;
     71else :
    6872    // or, if there's only 1 image, get the URL of the image
    6973    $next_attachment_url = wp_get_attachment_url();
    70 }
     74endif;
    7175?>
    7276                                <a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"><?php
Note: See TracChangeset for help on using the changeset viewer.