]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-content/themes/twentyten/loop.php
WordPress 3.4
[autoinstalls/wordpress.git] / wp-content / themes / twentyten / loop.php
index 84c167dc466a02f28b7531b1a7fa3a6a498c8b78..3e22fe2477f9c2d3bfc1c2985de16048fb52a4fe 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * The loop that displays posts.
  *
- * The loop displays the posts and the post content.  See
+ * The loop displays the posts and the post content. See
  * http://codex.wordpress.org/The_Loop to understand it and
  * http://codex.wordpress.org/Template_Tags to understand
  * the tags used in it.
@@ -55,9 +55,9 @@
         */ ?>
 <?php while ( have_posts() ) : the_post(); ?>
 
-<?php /* How to display posts in the Gallery category. */ ?>
+<?php /* How to display posts of the Gallery format. The gallery category is the old way. */ ?>
 
-       <?php if ( in_category( _x('gallery', 'gallery category slug', 'twentyten') ) ) : ?>
+       <?php if ( ( function_exists( 'get_post_format' ) && 'gallery' == get_post_format( $post->ID ) ) || in_category( _x( 'gallery', 'gallery category slug', 'twentyten' ) ) ) : ?>
                <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                        <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
 
 <?php if ( post_password_required() ) : ?>
                                <?php the_content(); ?>
 <?php else : ?>
-                               <div class="gallery-thumb">
-<?php
-       $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
-       $total_images = count( $images );
-       $image = array_shift( $images );
-       $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
-?>
-                                       <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
-                               </div><!-- .gallery-thumb -->
-                               <p><em><?php printf( __( 'This gallery contains <a %1$s>%2$s photos</a>.', 'twentyten' ),
-                                               'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"',
-                                               $total_images
-                                       ); ?></em></p>
-
-                               <?php the_excerpt(); ?>
+                               <?php
+                                       $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
+                                       if ( $images ) :
+                                               $total_images = count( $images );
+                                               $image = array_shift( $images );
+                                               $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
+                               ?>
+                                               <div class="gallery-thumb">
+                                                       <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
+                                               </div><!-- .gallery-thumb -->
+                                               <p><em><?php printf( _n( 'This gallery contains <a %1$s>%2$s photo</a>.', 'This gallery contains <a %1$s>%2$s photos</a>.', $total_images, 'twentyten' ),
+                                                               'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"',
+                                                               number_format_i18n( $total_images )
+                                                       ); ?></em></p>
+                               <?php endif; ?>
+                                               <?php the_excerpt(); ?>
 <?php endif; ?>
                        </div><!-- .entry-content -->
 
                        <div class="entry-utility">
-                               <a href="<?php echo get_term_link( _x('gallery', 'gallery category slug', 'twentyten'), 'category' ); ?>" title="<?php esc_attr_e( 'View posts in the Gallery category', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a>
+                       <?php if ( function_exists( 'get_post_format' ) && 'gallery' == get_post_format( $post->ID ) ) : ?>
+                               <a href="<?php echo get_post_format_link( 'gallery' ); ?>" title="<?php esc_attr_e( 'View Galleries', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a>
+                               <span class="meta-sep">|</span>
+                       <?php elseif ( in_category( _x( 'gallery', 'gallery category slug', 'twentyten' ) ) ) : ?>
+                               <a href="<?php echo get_term_link( _x( 'gallery', 'gallery category slug', 'twentyten' ), 'category' ); ?>" title="<?php esc_attr_e( 'View posts in the Gallery category', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a>
                                <span class="meta-sep">|</span>
+                       <?php endif; ?>
                                <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
                                <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
                        </div><!-- .entry-utility -->
                </div><!-- #post-## -->
 
-<?php /* How to display posts in the asides category */ ?>
+<?php /* How to display posts of the Aside format. The asides category is the old way. */ ?>
 
-       <?php elseif ( in_category( _x('asides', 'asides category slug', 'twentyten') ) ) : ?>
+       <?php elseif ( ( function_exists( 'get_post_format' ) && 'aside' == get_post_format( $post->ID ) ) || in_category( _x( 'asides', 'asides category slug', 'twentyten' ) )  ) : ?>
                <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
 
                <?php if ( is_archive() || is_search() ) : // Display excerpts for archives and search. ?>