Advertisement
Guest User

loop.php

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