Advertisement
alchymyth

content-gallery.php for twentytelve

Mar 4th, 2013
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.37 KB | None | 0 0
  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 if ( is_single() ) : ?>
  17.             <h1 class="entry-title"><?php the_title(); ?></h1>
  18.             <?php else : ?>
  19.             <h1 class="entry-title">
  20.                 <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>
  21.             </h1>
  22.             <?php endif; // is_single() ?>
  23.             <?php if ( comments_open() ) : ?>
  24.                 <div class="comments-link">
  25.                     <?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
  26.                 </div><!-- .comments-link -->
  27.             <?php endif; // comments_open() ?>
  28.         </header><!-- .entry-header -->
  29.  
  30.     <?php if ( is_search() ) : // Only display Excerpts for search pages ?>
  31.         <div class="entry-summary">
  32.             <?php the_excerpt(); ?>
  33.         </div><!-- .entry-summary -->
  34.         <?php else : ?>
  35.         <div class="entry-content">
  36.             <?php if ( post_password_required() ) : ?>
  37.                 <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
  38.  
  39.             <?php else : ?>
  40.                 <?php
  41.                     $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
  42.                     if ( $images ) :
  43.                         $total_images = count( $images );
  44.                         $image = array_shift( $images );
  45.                         $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
  46.                 ?>
  47.  
  48.                 <figure class="gallery-thumb">
  49.                     <a href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
  50.                 </figure><!-- .gallery-thumb -->
  51.  
  52.                 <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' ),
  53.                         'href="' . esc_url( get_permalink() ) . '" title="' . esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ) . '" rel="bookmark"',
  54.                         number_format_i18n( $total_images )
  55.                     ); ?></em></p>
  56.             <?php endif; ?>
  57.             <?php the_excerpt(); ?>
  58.         <?php endif; ?>
  59.         <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentytwelve' ) . '</span>', 'after' => '</div>' ) ); ?>
  60.     </div><!-- .entry-content -->
  61.     <?php endif; ?>
  62.  
  63.     <footer class="entry-meta">
  64.         <?php $show_sep = false; ?>
  65.         <?php
  66.             /* translators: used between list items, there is a space after the comma */
  67.             $categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) );
  68.             if ( $categories_list ):
  69.         ?>
  70.         <span class="cat-links">
  71.             <?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentytwelve' ), 'entry-utility-prep entry-utility-prep-cat-links', $categories_list );
  72.             $show_sep = true; ?>
  73.         </span>
  74.         <?php endif; // End if categories ?>
  75.         <?php
  76.             /* translators: used between list items, there is a space after the comma */
  77.             $tags_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );
  78.             if ( $tags_list ):
  79.             if ( $show_sep ) : ?>
  80.         <span class="sep"> | </span>
  81.             <?php endif; // End if $show_sep ?>
  82.         <span class="tag-links">
  83.             <?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentytwelve' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list );
  84.             $show_sep = true; ?>
  85.         </span>
  86.         <?php endif; // End if $tags_list ?>
  87.  
  88.         <?php if ( comments_open() ) : ?>
  89.         <?php if ( $show_sep ) : ?>
  90.         <span class="sep"> | </span>
  91.         <?php endif; // End if $show_sep ?>
  92.         <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>
  93.         <?php endif; // End if comments_open() ?>
  94.  
  95.         <?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
  96.     </footer><!-- .entry-meta -->
  97. </article><!-- #post-<?php the_ID(); ?> -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement