Make WordPress Core


Ignore:
Timestamp:
02/14/2010 07:13:34 AM (14 years ago)
Author:
dd32
Message:

Move the Loop into a separate file. Reduces code duplication and adds Gallery/Aside styling to all archive views. See #9015

File:
1 edited

Legend:

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

    r13128 r13141  
    44            <div id="content">
    55
    6 <?php global $wp_query; $total_pages = $wp_query->max_num_pages; if ( $total_pages > 1 ) { ?>
    7                 <div id="nav-above" class="navigation">
    8                     <div class="nav-previous"><?php next_posts_link(__( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' )); ?></div>
    9                     <div class="nav-next"><?php previous_posts_link(__( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' )); ?></div>
    10                 </div><!-- #nav-above -->
    11 <?php } ?>
    12 
    13     <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    14     <?php if ( in_category( 'Gallery' ) ) { ?>
    15         <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    16             <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>
    17 
    18             <div class="entry-meta">
    19                 <span class="meta-prep meta-prep-author"><?php _e( 'Posted on ', 'twentyten' ); ?></span>
    20                 <a href="<?php the_permalink(); ?>" title="<?php the_time(); ?>" rel="bookmark"><span class="entry-date"><?php echo get_the_date(); ?></span></a>
    21                 <span class="meta-sep"> <?php _e( 'by ', 'twentyten' ); ?> </span>
    22                 <span class="author vcard"><a class="url fn n" href="<?php echo get_author_posts_url( $authordata->ID ); ?>" title="<?php printf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ); ?>"><?php the_author(); ?></a></span>
    23             </div><!-- .entry-meta -->
    24 
    25             <div class="entry-content">
    26                 <div class="gallery-thumb">
    27                     <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php
    28                     $images =& get_children( array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999) );
    29                     $total_images = count($images);
    30                     $image = array_shift($images);
    31                     echo wp_get_attachment_image( $image->ID, 'thumbnail' );
    32                     ?></a>
    33                 </div>
    34                 <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>
    35 
    36                 <?php the_excerpt( '' ); ?>
    37             </div><!-- .entry-content -->
    38 
    39             <div class="entry-utility">
    40                 <?php
    41                     $category_id = get_cat_ID( 'Gallery' );
    42                     $category_link = get_category_link( $category_id );
    43                 ?>
    44                 <a href="<?php echo $category_link; ?>" title="<?php esc_attr_e('View posts in the Gallery category', 'twentyten'); ?>"><?php _e('More Galleries', 'twentyten'); ?></a>
    45                 <span class="meta-sep"><?php __( ' | ', 'twentyten' ); ?></span>
    46                 <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
    47                 <?php edit_post_link( __( 'Edit', 'twentyten' ), "<span class=\"meta-sep\">|</span>\n\t\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t\n" ); ?>
    48             </div><!-- #entry-utility -->
    49         </div>
    50 
    51 
    52     <?php } elseif ( in_category( 'asides' ) ) { ?>
    53         <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    54             <div class="entry-content">
    55                 <?php the_content( __( 'Continue&nbsp;reading&nbsp;<span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
    56             </div><!-- .entry-content -->
    57 
    58             <div class="entry-utility">
    59                 <span class="meta-prep meta-prep-author"><?php _e( 'Posted on ', 'twentyten' ); ?></span>
    60                 <a href="<?php the_permalink(); ?>" title="<?php the_time(); ?>" rel="bookmark"><span class="entry-date"><?php echo get_the_date(); ?></span></a>
    61                 <span class="meta-sep"> <?php _e( 'by ', 'twentyten' ); ?> </span>
    62                 <span class="author vcard"><a class="url fn n" href="<?php echo get_author_posts_url( $authordata->ID ); ?>" title="<?php printf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ); ?>"><?php the_author(); ?></a></span>
    63                 <span class="meta-sep"><?php __( ' | ', 'twentyten' ); ?></span>
    64                 <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
    65                 <?php edit_post_link( __( 'Edit', 'twentyten' ), "<span class=\"meta-sep\">|</span>\n\t\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t\n" ); ?>
    66             </div><!-- #entry-utility -->
    67         </div><!-- #post-<?php the_ID(); ?> -->
    68 
    69 
    70     <?php } else { ?>
    71         <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    72             <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>
    73 
    74             <div class="entry-meta">
    75                 <span class="meta-prep meta-prep-author"><?php _e('Posted on ', 'twentyten'); ?></span>
    76                 <a href="<?php
    77 the_permalink(); ?>" title="<?php the_time(); ?>" rel="bookmark"><span class="entry-date"><?php echo get_the_date(); ?></span></a>
    78                 <span class="meta-sep"><?php _e( ' by ', 'twentyten' ); ?></span>
    79                 <span class="author vcard"><a class="url fn n" href="<?php echo get_author_posts_url( $authordata->ID ); ?>" title="<?php printf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ); ?>"><?php the_author(); ?></a></span>
    80             </div><!-- .entry-meta -->
    81 
    82             <div class="entry-content">
    83                 <?php the_content( __( 'Continue&nbsp;reading&nbsp;<span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
    84                 <?php wp_link_pages('before=<div class="page-link">' . __( 'Pages:', 'twentyten' ) . '&after=</div>'); ?>
    85             </div><!-- .entry-content -->
    86 
    87             <div class="entry-utility">
    88                 <span class="cat-links"><span class="entry-utility-prep entry-utility-prep-cat-links"><?php _e( 'Posted in ', 'twentyten' ); ?></span><?php echo get_the_category_list( ', ' ); ?></span>
    89                 <span class="meta-sep"><?php __( ' | ', 'twentyten' ); ?></span>
    90                 <?php the_tags( '<span class="tag-links"><span class="entry-utility-prep entry-utility-prep-tag-links">' . __('Tagged ', 'twentyten' ) . '</span>', ", ", "</span>\n\t\t\t\t\t\t<span class=\"meta-sep\">|</span>\n" ); ?>
    91                 <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
    92                 <?php edit_post_link( __( 'Edit', 'twentyten' ), "<span class=\"meta-sep\">|</span>\n\t\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t\n" ); ?>
    93             </div><!-- #entry-utility -->
    94         </div><!-- #post-<?php the_ID(); ?> -->
    95 
    96         <?php comments_template( '', true ); ?>
    97 
    98     <?php } ?>
    99     <?php endwhile; ?>
    100     <?php else : ?>
     6    <?php if ( have_posts() ) :
     7        include 'loop.php';
     8    else : ?>
    1019        <h2><?php _e( 'Not Found', 'twentyten' ); ?></h2>
    10210        <div class="entry-content">
     
    10614    <?php endif; ?>
    10715
    108 <?php global $wp_query; $total_pages = $wp_query->max_num_pages; if ( $total_pages > 1 ) { ?>
    109                 <div id="nav-below" class="navigation">
    110                     <div class="nav-previous"><?php next_posts_link(__( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' )); ?></div>
    111                     <div class="nav-next"><?php previous_posts_link(__( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' )); ?></div>
    112                 </div><!-- #nav-below -->
    113 <?php } ?>
    114 
    11516            </div><!-- #content -->
    11617        </div><!-- #container -->
Note: See TracChangeset for help on using the changeset viewer.