From 34d41e32ba4019aa5d5927fdba4de123e0598372 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 27 Sep 2012 07:01:16 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@22048 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-content/themes/twentytwelve/archive.php | 32 +++---------- wp-content/themes/twentytwelve/author.php | 4 ++ wp-content/themes/twentytwelve/category.php | 51 ++++++++++++++++++++ wp-content/themes/twentytwelve/image.php | 18 ++++--- wp-content/themes/twentytwelve/index.php | 3 +- wp-content/themes/twentytwelve/tag.php | 52 +++++++++++++++++++++ 6 files changed, 127 insertions(+), 33 deletions(-) create mode 100644 wp-content/themes/twentytwelve/category.php create mode 100644 wp-content/themes/twentytwelve/tag.php diff --git a/wp-content/themes/twentytwelve/archive.php b/wp-content/themes/twentytwelve/archive.php index 210eaca7c3..8bfb01c903 100644 --- a/wp-content/themes/twentytwelve/archive.php +++ b/wp-content/themes/twentytwelve/archive.php @@ -6,7 +6,8 @@ * For example, puts together date-based pages if no date.php file exists. * * If you'd like to further customize these archive views, you may create a - * new template file for each specific one, like tag.php for Tag archives or + * new template file for each specific one. For example, Twenty Twelve already + * has tag.php for Tag archives, category.php for Category archives, and * author.php for Author archives. * * Learn more: http://codex.wordpress.org/Template_Hierarchy @@ -24,35 +25,16 @@ get_header(); ?>

' . get_the_date() . '' ); - } elseif ( is_month() ) { + elseif ( is_month() ) : printf( __( 'Monthly Archives: %s', 'twentytwelve' ), '' . get_the_date( _x( 'F Y', 'monthly archives date format', 'twentytwelve' ) ) . '' ); - } elseif ( is_year() ) { + elseif ( is_year() ) : printf( __( 'Yearly Archives: %s', 'twentytwelve' ), '' . get_the_date( _x( 'Y', 'yearly archives date format', 'twentytwelve' ) ) . '' ); - } elseif ( is_tag() ) { - printf( __( 'Tag Archives: %s', 'twentytwelve' ), '' . single_tag_title( '', false ) . '' ); - } elseif ( is_category() ) { - printf( __( 'Category Archives: %s', 'twentytwelve' ), '' . single_cat_title( '', false ) . '' ); - } else { + else : _e( 'Archives', 'twentytwelve' ); - } + endif; ?>

- - ' . $tag_description . ''; - } - // Show an optional category description. - if ( is_category() ) { - $category_description = category_description(); - if ( $category_description ) - echo '
' . $category_description . '
'; - } - ?>
+ +
+
+ + +
+

' . single_cat_title( '', false ) . '' ); ?>

+ + +
+ +
+ + + + + + + +
+
+ + + \ No newline at end of file diff --git a/wp-content/themes/twentytwelve/image.php b/wp-content/themes/twentytwelve/image.php index b3dc75c630..c84cc510cc 100644 --- a/wp-content/themes/twentytwelve/image.php +++ b/wp-content/themes/twentytwelve/image.php @@ -2,6 +2,8 @@ /** * The template for displaying image attachments. * + * Learn more: http://codex.wordpress.org/Template_Hierarchy + * * @package WordPress * @subpackage Twenty_Twelve * @since Twenty Twelve 1.0 @@ -51,23 +53,25 @@ get_header(); ?> * or the first image (if we're looking at the last image in a gallery), or, in a gallery of one, just the link to that image file */ $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' ) ) ); -foreach ( $attachments as $k => $attachment ) { +foreach ( $attachments as $k => $attachment ) : if ( $attachment->ID == $post->ID ) break; -} +endforeach; + $k++; // If there is more than 1 attachment in a gallery -if ( count( $attachments ) > 1 ) { - if ( isset( $attachments[ $k ] ) ) +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 + else : // or get the URL of the first image attachment $next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID ); -} else { + endif; +else : // or, if there's only 1 image, get the URL of the image $next_attachment_url = wp_get_attachment_url(); -} +endif; ?> + +
+
+ + +
+

' . single_tag_title( '', false ) . '' ); ?>

+ + +
+ + +
+ + + + + + + +
+
+ + + \ No newline at end of file