Advertisement
Guest User

loop-index.php

a guest
Jun 25th, 2011
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.55 KB | None | 0 0
  1. <?php
  2. /**
  3. * The loop that displays posts.
  4. *
  5. * The loop displays the posts and the post content. See
  6. * http://codex.wordpress.org/The_Loop to understand it and
  7. * http://codex.wordpress.org/Template_Tags to understand
  8. * the tags used in it.
  9. *
  10. * This can be overridden in child themes with loop.php or
  11. * loop-template.php, where 'template' is the loop context
  12. * requested by a template. For example, loop-index.php would
  13. * be used if it exists and we ask for the loop with:
  14. * <code>get_template_part( 'loop', 'index' );</code>
  15. *
  16. * @package WordPress
  17. * @subpackage Speaky
  18. * @since Speaky 1.0
  19. */
  20. ?>
  21.  
  22. <?php /* Display navigation to next/previous pages when applicable */ ?>
  23.  
  24. <?php /* If there are no posts to display, such as an empty archive page */ ?>
  25. <?php if ( ! have_posts() ) : ?>
  26. <div id="post-0" class="post error404 not-found">
  27. <h1 class="entry-title"><?php _e( 'Not Found', 'twentyten' ); ?></h1>
  28. <div class="entry-content">
  29. <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyten' ); ?></p>
  30. <?php get_search_form(); ?>
  31. </div><!-- .entry-content -->
  32. </div><!-- #post-0 -->
  33. <?php endif; ?>
  34.  
  35. <?php
  36. /* Start the Loop.
  37. *
  38. * In Twenty Ten we use the same loop in multiple contexts.
  39. * It is broken into three main parts: when we're displaying
  40. * posts that are in the gallery category, when we're displaying
  41. * posts in the asides category, and finally all other posts.
  42. *
  43. * Additionally, we sometimes check for whether we are on an
  44. * archive page, a search page, etc., allowing for small differences
  45. * in the loop on each template without actually duplicating
  46. * the rest of the loop that is shared.
  47. *
  48. * Without further ado, the loop:
  49. */ ?>
  50. <?php while ( have_posts() ) : the_post(); ?>
  51.  
  52. <?php /* How to display posts in the Gallery category. */ ?>
  53.  
  54. <?php if ( in_category( _x('gallery', 'gallery category slug', 'twentyten') ) ) : ?>
  55. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  56. <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>
  57.  
  58. <div class="entry-meta">
  59. <?php twentyten_posted_on(); ?>
  60. </div><!-- .entry-meta -->
  61.  
  62. <div class="entry-content">
  63. <?php if ( post_password_required() ) : ?>
  64. <?php the_content(); ?>
  65. <?php else : ?>
  66. <div class="gallery-thumb">
  67. <?php
  68. $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
  69. $total_images = count( $images );
  70. $image = array_shift( $images );
  71. $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
  72. ?>
  73. <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
  74. </div><!-- .gallery-thumb -->
  75. <p><em><?php printf( __( 'This gallery contains <a %1$s>%2$s photos</a>.', 'twentyten' ),
  76. 'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"',
  77. $total_images
  78. ); ?></em></p>
  79.  
  80. <?php the_excerpt(); ?>
  81. <?php endif; ?>
  82. </div><!-- .entry-content -->
  83.  
  84. <div class="entry-utility">
  85. <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>
  86.  
  87. <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
  88. <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
  89. </div><!-- .entry-utility -->
  90. </div><!-- #post-## -->
  91.  
  92. <?php /* How to display posts in the asides category */ ?>
  93.  
  94. <?php elseif ( in_category( _x('asides', 'asides category slug', 'twentyten') ) ) : ?>
  95. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  96.  
  97. <?php if ( is_archive() || is_search() ) : // Display excerpts for archives and search. ?>
  98. <div class="entry-summary">
  99. <?php the_excerpt(); ?>
  100. </div><!-- .entry-summary -->
  101. <?php else : ?>
  102. <div class="entry-content">
  103. <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
  104. </div><!-- .entry-content -->
  105. <?php endif; ?>
  106.  
  107. <div class="entry-utility">
  108. <?php twentyten_posted_on(); ?>
  109.  
  110. <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
  111. <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
  112. </div><!-- .entry-utility -->
  113. </div><!-- #post-## -->
  114.  
  115. <?php /* How to display all other posts. */ ?>
  116.  
  117. <?php else : ?>
  118. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  119. <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>
  120.  
  121. <div class="entry-meta">
  122. <?php twentyten_posted_on(); ?>
  123. </div><!-- .entry-meta -->
  124.  
  125. <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
  126. <div class="entry-summary">
  127. <?php the_excerpt(); ?>
  128. </div><!-- .entry-summary -->
  129. <?php else : ?>
  130. <div class="entry-content">
  131. <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
  132. <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
  133. </div><!-- .entry-content -->
  134. <?php endif; ?>
  135.  
  136. <div class="entry-utility">
  137. <?php if ( count( get_the_category() ) ) : ?>
  138. <span class="cat-links">
  139. <?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
  140. </span>
  141.  
  142. <?php endif; ?>
  143. <?php
  144. $tags_list = get_the_tag_list( '', ', ' );
  145. if ( $tags_list ):
  146. ?>
  147. <span class="tag-links">
  148. <?php printf( __( '<span class="meta-sep">|</span> <span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
  149. </span>
  150.  
  151. <?php endif; ?>
  152. <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
  153. <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
  154. </div><!-- .entry-utility -->
  155. </div><!-- #post-## -->
  156.  
  157. <?php comments_template( '', true ); ?>
  158.  
  159. <?php endif; // This was the if statement that broke the loop into three parts based on categories. ?>
  160.  
  161. <?php endwhile; // End the loop. Whew. ?>
  162.  
  163. <?php /* Display navigation to next/previous pages when applicable */ ?>
  164. <?php if ( $wp_query->max_num_pages > 1 ) : ?>
  165. <div id="nav-below" class="navigation">
  166. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
  167. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
  168. </div><!-- #nav-below -->
  169. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement