loop.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. * @package WordPress
  11. * @subpackage Twenty Ten
  12. * @since 3.0.0
  13. */
  14. ?>
  15. <?php /* Display navigation to next/previous pages when applicable */ ?>
  16. <?php if ( $wp_query->max_num_pages > 1 ) : ?>
  17. <div id="nav-above" class="navigation">
  18. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
  19. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
  20. </div><!-- #nav-above -->
  21. <?php endif; ?>
  22. <?php /* If there are no posts to display, such as an empty archive page */ ?>
  23. <?php if ( ! have_posts() ) : ?>
  24. <div id="post-0" class="post error404 not-found">
  25. <h1 class="entry-title"><?php _e( 'Not Found', 'twentyten' ); ?></h1>
  26. <div class="entry-content">
  27. <p><?php _e( 'Apologies, but no results were found for the requested Archive. Perhaps searching will help find a related post.', 'twentyten' ); ?></p>
  28. <?php get_search_form(); ?>
  29. </div><!-- .entry-content -->
  30. </div><!-- #post-0 -->
  31. <?php endif; ?>
  32. <?php /* Start the Loop */ ?>
  33. <?php while ( have_posts() ) : the_post(); ?>
  34. <?php /* How to Display posts in the Gallery Category */ ?>
  35. <?php if ( in_category( 'Gallery' ) ) : ?>
  36. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  37. <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>
  38. <div class="entry-meta">
  39. <?php
  40. printf( __( '<span class="meta-prep meta-prep-author">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep"> by </span> <span class="author vcard"><a class="url fn n" href="%4$s" title="%5$s">%6$s</a></span>', 'twentyten' ),
  41. get_permalink(),
  42. esc_attr( get_the_time() ),
  43. get_the_date(),
  44. get_author_posts_url( get_the_author_meta( 'ID' ) ),
  45. sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
  46. get_the_author()
  47. );
  48. ?>
  49. </div><!-- .entry-meta -->
  50. <div class="entry-content">
  51. <div class="gallery-thumb">
  52. <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php
  53. $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
  54. $total_images = count( $images );
  55. $image = array_shift( $images );
  56. echo wp_get_attachment_image( $image->ID, 'thumbnail' );
  57. ?></a>
  58. </div>
  59. <p><em><?php printf( __( 'This gallery contains <a %1$s>%2$s photos</a>.', 'twentyten' ),
  60. 'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"',
  61. $total_images
  62. ); ?></em></p>
  63. <?php the_excerpt( '' ); ?>
  64. </div><!-- .entry-content -->
  65. <div class="entry-utility">
  66. <?php
  67. $category_id = get_cat_ID( 'Gallery' );
  68. $category_link = get_category_link( $category_id );
  69. ?>
  70. <a href="<?php echo $category_link; ?>" title="<?php esc_attr_e( 'View posts in the Gallery category', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a>
  71. <span class="meta-sep"> | </span>
  72. <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
  73. <?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" ); ?>
  74. </div><!-- #entry-utility -->
  75. </div>
  76. <?php /* How to display posts in the asides category */ ?>
  77. <?php elseif ( in_category( 'asides' ) ) : ?>
  78. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  79. <?php if ( is_archive() || is_search() ) : //Only display Excerpts for archives & search ?>
  80. <div class="entry-summary">
  81. <?php the_excerpt( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
  82. </div><!-- .entry-summary -->
  83. <?php else : ?>
  84. <div class="entry-content">
  85. <?php the_content( __( 'Continue&nbsp;reading&nbsp;<span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
  86. </div><!-- .entry-content -->
  87. <?php endif; ?>
  88. <div class="entry-utility">
  89. <?php
  90. printf( __( '<span class="meta-prep meta-prep-author">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep"> by </span> <span class="author vcard"><a class="url fn n" href="%4$s" title="%5$s">%6$s</a></span>', 'twentyten' ),
  91. get_permalink(),
  92. esc_attr( get_the_time() ),
  93. get_the_date(),
  94. get_author_posts_url( get_the_author_meta( 'ID' ) ),
  95. sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
  96. get_the_author()
  97. );
  98. ?>
  99. <span class="meta-sep"> | </span>
  100. <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
  101. <?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" ); ?>
  102. </div><!-- #entry-utility -->
  103. </div><!-- #post-<?php the_ID(); ?> -->
  104. <?php /* How to display all other posts */ ?>
  105. <?php else : ?>
  106. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  107. <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>
  108. <div class="entry-meta">
  109. <?php
  110. printf( __( '<span class="meta-prep meta-prep-author">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep"> by </span> <span class="author vcard"><a class="url fn n" href="%4$s" title="%5$s">%6$s</a></span>', 'twentyten' ),
  111. get_permalink(),
  112. esc_attr( get_the_time() ),
  113. get_the_date(),
  114. get_author_posts_url( get_the_author_meta( 'ID' ) ),
  115. sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
  116. get_the_author()
  117. );
  118. ?>
  119. </div><!-- .entry-meta -->
  120. <?php if ( is_archive() || is_search() ) : //Only display Excerpts for archives & search ?>
  121. <div class="entry-summary">
  122. <?php the_excerpt( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
  123. </div><!-- .entry-summary -->
  124. <?php else : ?>
  125. <div class="entry-content">
  126. <?php the_content( __( 'Continue&nbsp;reading&nbsp;<span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
  127. <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
  128. </div><!-- .entry-content -->
  129. <?php endif; ?>
  130. <div class="entry-utility">
  131. <span class="cat-links"><span class="entry-utility-prep entry-utility-prep-cat-links"><?php echo twentyten_cat_list(); ?></span></span>
  132. <span class="meta-sep"> | </span>
  133. <?php $tags_text = twentyten_tag_list(); ?>
  134. <?php if ( ! empty( $tags_text ) ) : ?>
  135. <span class="tag-links"><span class="entry-utility-prep entry-utility-prep-tag-links"><?php echo $tags_text; ?></span></span>
  136. <span class="meta-sep"> | </span>
  137. <?php endif; //$tags_text ?>
  138. <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
  139. <?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" ); ?>
  140. </div><!-- #entry-utility -->
  141. </div><!-- #post-<?php the_ID(); ?> -->
  142. <?php comments_template( '', true ); ?>
  143. <?php endif; // if different categories queried ?>
  144. <?php endwhile; ?>
  145. <?php /* Display navigation to next/previous pages when applicable */ ?>
  146. <?php if ( $wp_query->max_num_pages > 1 ) : ?>
  147. <div id="nav-below" class="navigation">
  148. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
  149. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
  150. </div><!-- #nav-below -->
  151. <?php endif; ?>