[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * The loop that displays posts 4 * 5 * The loop displays the posts and the post content. See 6 * https://developer.wordpress.org/themes/basics/the-loop/ to understand it and 7 * https://developer.wordpress.org/themes/basics/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">←</span> Older posts', 'twentyten' ) ); ?></div> 26 <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</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 <?php 42 /* 43 * Start the Loop. 44 * 45 * In Twenty Ten we use the same loop in multiple contexts. 46 * It is broken into three main parts: when we're displaying 47 * posts that are in the gallery category, when we're displaying 48 * posts in the asides category, and finally all other posts. 49 * 50 * Additionally, we sometimes check for whether we are on an 51 * archive page, a search page, etc., allowing for small differences 52 * in the loop on each template without actually duplicating 53 * the rest of the loop that is shared. 54 * 55 * Without further ado, the loop: 56 */ 57 ?> 58 <?php 59 while ( have_posts() ) : 60 the_post(); 61 ?> 62 63 <?php /* How to display posts of the Gallery format. The gallery category is the old way. */ ?> 64 65 <?php if ( ( function_exists( 'get_post_format' ) && 'gallery' === get_post_format( $post->ID ) ) || in_category( _x( 'gallery', 'gallery category slug', 'twentyten' ) ) ) : ?> 66 <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 67 <h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2> 68 69 <div class="entry-meta"> 70 <?php twentyten_posted_on(); ?> 71 </div><!-- .entry-meta --> 72 73 <div class="entry-content"> 74 <?php if ( post_password_required() ) : ?> 75 <?php the_content(); ?> 76 <?php else : ?> 77 <?php 78 $images = twentyten_get_gallery_images(); 79 if ( $images ) : 80 $total_images = count( $images ); 81 $image = reset( $images ); 82 ?> 83 <div class="gallery-thumb"> 84 <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo wp_get_attachment_image( $image, 'thumbnail' ); ?></a> 85 </div><!-- .gallery-thumb --> 86 <p><em> 87 <?php 88 printf( 89 /* translators: 1: HTML tag attributes, 2: Image count. */ 90 _n( 'This gallery contains <a %1$s>%2$s photo</a>.', 'This gallery contains <a %1$s>%2$s photos</a>.', $total_images, 'twentyten' ), 91 /* translators: %s: Post title. */ 92 'href="' . esc_url( get_permalink() ) . '" title="' . esc_attr( sprintf( __( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) ) . '" rel="bookmark"', 93 number_format_i18n( $total_images ) 94 ); 95 ?> 96 </em></p> 97 <?php endif; // End twentyten_get_gallery_images() check. ?> 98 <?php the_excerpt(); ?> 99 <?php endif; ?> 100 </div><!-- .entry-content --> 101 102 <div class="entry-utility"> 103 <?php 104 $gallery = get_term_by( 'slug', _x( 'gallery', 'gallery category slug', 'twentyten' ), 'category' ); 105 if ( function_exists( 'get_post_format' ) && 'gallery' === get_post_format( $post->ID ) ) : 106 ?> 107 <a href="<?php echo esc_url( get_post_format_link( 'gallery' ) ); ?>" title="<?php esc_attr_e( 'View Galleries', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a> 108 <span class="meta-sep">|</span> 109 <?php elseif ( $gallery && in_category( $gallery->term_id ) ) : ?> 110 <a href="<?php echo esc_url( get_category_link( $gallery ) ); ?>" title="<?php esc_attr_e( 'View posts in the Gallery category', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a> 111 <span class="meta-sep">|</span> 112 <?php endif; ?> 113 <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span> 114 <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?> 115 </div><!-- .entry-utility --> 116 </div><!-- #post-<?php the_ID(); ?> --> 117 118 <?php /* How to display posts of the Aside format. The asides category is the old way. */ ?> 119 120 <?php elseif ( ( function_exists( 'get_post_format' ) && 'aside' === get_post_format( $post->ID ) ) || in_category( _x( 'asides', 'asides category slug', 'twentyten' ) ) ) : ?> 121 <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 122 123 <?php if ( is_archive() || is_search() ) : // Display excerpts for archives and search. ?> 124 <div class="entry-summary"> 125 <?php the_excerpt(); ?> 126 </div><!-- .entry-summary --> 127 <?php else : ?> 128 <div class="entry-content"> 129 <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?> 130 </div><!-- .entry-content --> 131 <?php endif; ?> 132 133 <div class="entry-utility"> 134 <?php twentyten_posted_on(); ?> 135 <span class="meta-sep">|</span> 136 <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span> 137 <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?> 138 </div><!-- .entry-utility --> 139 </div><!-- #post-<?php the_ID(); ?> --> 140 141 <?php /* How to display all other posts. */ ?> 142 143 <?php else : ?> 144 <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 145 <h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2> 146 147 <div class="entry-meta"> 148 <?php twentyten_posted_on(); ?> 149 </div><!-- .entry-meta --> 150 151 <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?> 152 <div class="entry-summary"> 153 <?php the_excerpt(); ?> 154 </div><!-- .entry-summary --> 155 <?php else : ?> 156 <div class="entry-content"> 157 <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?> 158 <?php 159 wp_link_pages( 160 array( 161 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 162 'after' => '</div>', 163 ) 164 ); 165 ?> 166 </div><!-- .entry-content --> 167 <?php endif; ?> 168 169 <div class="entry-utility"> 170 <?php if ( count( get_the_category() ) ) : ?> 171 <span class="cat-links"> 172 <?php 173 /* translators: 1: CSS classes, 2: Category list. */ 174 printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); 175 ?> 176 </span> 177 <span class="meta-sep">|</span> 178 <?php endif; ?> 179 180 <?php 181 $tags_list = get_the_tag_list( '', ', ' ); 182 if ( $tags_list && ! is_wp_error( $tags_list ) ) : 183 ?> 184 <span class="tag-links"> 185 <?php 186 /* translators: 1: CSS classes, 2: Category list. */ 187 printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); 188 ?> 189 </span> 190 <span class="meta-sep">|</span> 191 <?php endif; ?> 192 193 <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span> 194 195 <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?> 196 </div><!-- .entry-utility --> 197 </div><!-- #post-<?php the_ID(); ?> --> 198 199 <?php comments_template( '', true ); ?> 200 201 <?php endif; // This was the if statement that broke the loop into three parts based on categories. ?> 202 203 <?php endwhile; // End of the loop. Whew. ?> 204 205 <?php // Display navigation to next/previous pages when applicable. ?> 206 <?php if ( $wp_query->max_num_pages > 1 ) : ?> 207 <div id="nav-below" class="navigation"> 208 <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyten' ) ); ?></div> 209 <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div> 210 </div><!-- #nav-below --> 211 <?php endif; ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Thu Nov 21 08:20:01 2024 | Cross-referenced by PHPXref |