Advertisement
Viper007Bond

Untitled

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