Make WordPress Core

Changeset 22048


Ignore:
Timestamp:
09/27/2012 07:01:16 AM (12 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.

Location:
trunk/wp-content/themes/twentytwelve
Files:
2 added
4 edited

Legend:

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

    r21992 r22048  
    77 *
    88 * If you'd like to further customize these archive views, you may create a
    9  * new template file for each specific one, like tag.php for Tag archives or
     9 * new template file for each specific one. For example, Twenty Twelve already
     10 * has tag.php for Tag archives, category.php for Category archives, and
    1011 * author.php for Author archives.
    1112 *
     
    2526            <header class="archive-header">
    2627                <h1 class="archive-title"><?php
    27                     if ( is_day() ) {
     28                    if ( is_day() ) :
    2829                        printf( __( 'Daily Archives: %s', 'twentytwelve' ), '<span>' . get_the_date() . '</span>' );
    29                     } elseif ( is_month() ) {
     30                    elseif ( is_month() ) :
    3031                        printf( __( 'Monthly Archives: %s', 'twentytwelve' ), '<span>' . get_the_date( _x( 'F Y', 'monthly archives date format', 'twentytwelve' ) ) . '</span>' );
    31                     } elseif ( is_year() ) {
     32                    elseif ( is_year() ) :
    3233                        printf( __( 'Yearly Archives: %s', 'twentytwelve' ), '<span>' . get_the_date( _x( 'Y', 'yearly archives date format', 'twentytwelve' ) ) . '</span>' );
    33                     } elseif ( is_tag() ) {
    34                         printf( __( 'Tag Archives: %s', 'twentytwelve' ), '<span>' . single_tag_title( '', false ) . '</span>' );
    35                     } elseif ( is_category() ) {
    36                         printf( __( 'Category Archives: %s', 'twentytwelve' ), '<span>' . single_cat_title( '', false ) . '</span>' );
    37                     } else {
     34                    else :
    3835                        _e( 'Archives', 'twentytwelve' );
    39                     }
     36                    endif;
    4037                ?></h1>
    41 
    42                 <?php
    43                     // Show an optional tag description.
    44                     if ( is_tag() ) {
    45                         $tag_description = tag_description();
    46                         if ( $tag_description )
    47                             echo '<div class="archive-meta">' . $tag_description . '</div>';
    48                     }
    49                     // Show an optional category description.
    50                     if ( is_category() ) {
    51                         $category_description = category_description();
    52                         if ( $category_description )
    53                             echo '<div class="archive-meta">' . $category_description . '</div>';
    54                     }
    55                 ?>
    5638            </header><!-- .archive-header -->
    5739
  • trunk/wp-content/themes/twentytwelve/author.php

    r21941 r22048  
    22/**
    33 * The template for displaying Author Archive pages.
     4 *
     5 * Used to display archive-type pages for posts by an author.
     6 *
     7 * Learn more: http://codex.wordpress.org/Template_Hierarchy
    48 *
    59 * @package WordPress
  • 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
  • trunk/wp-content/themes/twentytwelve/index.php

    r21763 r22048  
    66 * and one of the two required files for a theme (the other being style.css).
    77 * It is used to display a page when nothing more specific matches a query.
    8  * E.g., it puts together the home page when no home.php file exists.
     8 * For example, it puts together the home page when no home.php file exists.
     9 *
    910 * Learn more: http://codex.wordpress.org/Template_Hierarchy
    1011 *
Note: See TracChangeset for help on using the changeset viewer.