Advertisement
alchymyth

content-gallery.php for twentytwelve

Mar 19th, 2013
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * The template for displaying posts in the Gallery Post Format on index and archive pages
  4.  *
  5.  * Learn more: http://codex.wordpress.org/Post_Formats
  6.  *
  7.  * @package WordPress
  8.  * @subpackage Twenty_Twelve
  9.  */
  10. ?>
  11.  
  12. <?php if( is_single() ) { get_template_part( 'content' ); return; } //force normal single view of a 'gallery' post format ?>
  13.  
  14. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  15.         <header class="entry-header">
  16.             <?php the_post_thumbnail(); ?>
  17.             <h1 class="entry-title">
  18.                 <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
  19.             </h1>
  20.             <h3 class="entry-format"><?php _e( 'Gallery', 'twentytwelve' ); ?></h3>
  21.             <?php if ( comments_open() ) : ?>
  22.                 <div class="comments-link">
  23.                     <?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
  24.                 </div><!-- .comments-link -->
  25.             <?php endif; // comments_open() ?>
  26.         </header><!-- .entry-header -->
  27.  
  28.         <div class="entry-content">
  29.             <?php if ( post_password_required() ) : ?>
  30.                 <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
  31.  
  32.             <?php else : ?>
  33.                 <?php
  34.                     $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
  35.                     if ( $images ) :
  36.                         $total_images = count( $images );
  37.                         $image = array_shift( $images );
  38.                         $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
  39.                 ?>
  40.  
  41.                 <figure class="gallery-thumb">
  42.                     <a href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
  43.                 </figure><!-- .gallery-thumb -->
  44.  
  45.                 <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, 'twentytwelve' ),
  46.                         'href="' . esc_url( get_permalink() ) . '" title="' . esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ) . '" rel="bookmark"',
  47.                         number_format_i18n( $total_images )
  48.                     ); ?></em></p>
  49.             <?php endif; ?>
  50.             <?php the_excerpt(); ?>
  51.         <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentytwelve' ) . '</span>', 'after' => '</div>' ) ); ?>
  52.     </div><!-- .entry-content -->
  53.     <?php endif; ?>
  54.  
  55.     <footer class="entry-meta">
  56.         <?php $show_sep = false; ?>
  57.         <?php
  58.             /* translators: used between list items, there is a space after the comma */
  59.             $categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) );
  60.             if ( $categories_list ):
  61.         ?>
  62.         <span class="cat-links">
  63.             <?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentytwelve' ), 'entry-utility-prep entry-utility-prep-cat-links', $categories_list );
  64.             $show_sep = true; ?>
  65.         </span>
  66.         <?php endif; // End if categories ?>
  67.         <?php
  68.             /* translators: used between list items, there is a space after the comma */
  69.             $tags_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );
  70.             if ( $tags_list ):
  71.             if ( $show_sep ) : ?>
  72.         <span class="sep"> | </span>
  73.             <?php endif; // End if $show_sep ?>
  74.         <span class="tag-links">
  75.             <?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentytwelve' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list );
  76.             $show_sep = true; ?>
  77.         </span>
  78.         <?php endif; // End if $tags_list ?>
  79.  
  80.         <?php if ( comments_open() ) : ?>
  81.         <?php if ( $show_sep ) : ?>
  82.         <span class="sep"> | </span>
  83.         <?php endif; // End if $show_sep ?>
  84.         <span class="comments-link"><?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '<b>1</b> Reply', 'twentytwelve' ), __( '<b>%</b> Replies', 'twentytwelve' ) ); ?></span>
  85.         <?php endif; // End if comments_open() ?>
  86.  
  87.         <?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
  88.     </footer><!-- .entry-meta -->
  89. </article><!-- #post-<?php the_ID(); ?> -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement