- Timestamp:
- 08/17/2018 01:50:26 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyten/loop-attachment.php
r42343 r43571 20 20 while ( have_posts() ) : 21 21 the_post(); 22 ?>22 ?> 23 23 24 24 <?php if ( ! empty( $post->post_parent ) ) : ?> … … 27 27 /* translators: %s - title of parent post */ 28 28 printf( __( '<span class="meta-nav">←</span> %s', 'twentyten' ), get_the_title( $post->post_parent ) ); 29 ?>29 ?> 30 30 </a></p> 31 31 <?php endif; ?> … … 46 46 ) 47 47 ); 48 48 ?> 49 49 <span class="meta-sep">|</span> 50 50 <?php … … 78 78 <div class="entry-content"> 79 79 <div class="entry-attachment"> 80 <?php 81 if ( wp_attachment_is_image() ) : 82 $attachments = array_values( 83 get_children( 84 array( 85 'post_parent' => $post->post_parent, 86 'post_status' => 'inherit', 87 'post_type' => 'attachment', 88 'post_mime_type' => 'image', 89 'order' => 'ASC', 90 'orderby' => 'menu_order ID', 80 <?php 81 if ( wp_attachment_is_image() ) : 82 $attachments = array_values( 83 get_children( 84 array( 85 'post_parent' => $post->post_parent, 86 'post_status' => 'inherit', 87 'post_type' => 'attachment', 88 'post_mime_type' => 'image', 89 'order' => 'ASC', 90 'orderby' => 'menu_order ID', 91 ) 91 92 ) 92 ) 93 );94 foreach ( $attachments as $k => $attachment) {95 if ( $attachment->ID == $post->ID ) {96 break;93 ); 94 foreach ( $attachments as $k => $attachment ) { 95 if ( $attachment->ID == $post->ID ) { 96 break; 97 } 97 98 } 98 }99 99 100 // If there is more than 1 image attachment in a gallery 101 if ( count( $attachments ) > 1 ) { 102 $k++; 103 if ( isset( $attachments[ $k ] ) ) { 104 // get the URL of the next image attachment 105 $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); 106 } else { // or get the URL of the first image attachment 107 $next_attachment_url = get_attachment_link( $attachments[0]->ID ); 100 // If there is more than 1 image attachment in a gallery 101 if ( count( $attachments ) > 1 ) { 102 $k++; 103 if ( isset( $attachments[ $k ] ) ) { 104 // get the URL of the next image attachment 105 $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); 106 } else { // or get the URL of the first image attachment 107 $next_attachment_url = get_attachment_link( $attachments[0]->ID ); 108 } 109 } else { 110 // or, if there's only 1 image attachment, get the URL of the image 111 $next_attachment_url = wp_get_attachment_url(); 108 112 } 109 } else { 110 // or, if there's only 1 image attachment, get the URL of the image 111 $next_attachment_url = wp_get_attachment_url(); 112 } 113 ?> 113 ?> 114 114 <p class="attachment"><a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"> 115 115 <?php … … 131 131 $attachment_height = apply_filters( 'twentyten_attachment_height', 900 ); 132 132 echo wp_get_attachment_image( $post->ID, array( $attachment_width, $attachment_height ) ); // filterable image width with, essentially, no limit for image height. 133 ?>133 ?> 134 134 </a></p> 135 135 … … 138 138 <div class="nav-next"><?php next_image_link( false ); ?></div> 139 139 </div><!-- #nav-below --> 140 <?php else : ?>140 <?php else : ?> 141 141 <a href="<?php echo esc_url( wp_get_attachment_url() ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"><?php echo esc_html( basename( get_permalink() ) ); ?></a> 142 142 <?php endif; ?> … … 146 146 if ( ! empty( $post->post_excerpt ) ) { 147 147 the_excerpt();} 148 ?>148 ?> 149 149 </div> 150 150 151 <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?>152 <?php153 wp_link_pages(154 array(155 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ),156 'after' => '</div>',157 )158 );159 ?>151 <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?> 152 <?php 153 wp_link_pages( 154 array( 155 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 156 'after' => '</div>', 157 ) 158 ); 159 ?> 160 160 161 161 </div><!-- .entry-content --> … … 167 167 </div><!-- #post-## --> 168 168 169 <?php comments_template(); ?>169 <?php comments_template(); ?> 170 170 171 171 <?php endwhile;
Note: See TracChangeset
for help on using the changeset viewer.