PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/twentyeleven/content-gallery.php

https://github.com/coffeant/wordpress
PHP | 78 lines | 60 code | 9 blank | 9 comment | 6 complexity | a0c5228856c1dc74844cd2bbdedb3d61 MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1
  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 Eleven
  9. * @since Twenty Eleven 1.0
  10. */
  11. ?>
  12. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  13. <header class="entry-header">
  14. <hgroup>
  15. <h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
  16. <h2 class="entry-format">Gallery</h2>
  17. </hgroup>
  18. <div class="entry-meta">
  19. <?php
  20. printf( __( '<span class="sep">Posted on </span><a href="%1$s" rel="bookmark"><time class="entry-date" datetime="%2$s" pubdate>%3$s</time></a> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%4$s" title="%5$s">%6$s</a></span>', 'twentyeleven' ),
  21. get_permalink(),
  22. get_the_date( 'c' ),
  23. get_the_date(),
  24. get_author_posts_url( get_the_author_meta( 'ID' ) ),
  25. sprintf( esc_attr__( 'View all posts by %s', 'twentyeleven' ), get_the_author() ),
  26. get_the_author()
  27. );
  28. ?>
  29. </div><!-- .entry-meta -->
  30. </header><!-- .entry-header -->
  31. <?php if ( is_search() ) : // Only display Excerpts for search pages ?>
  32. <div class="entry-summary">
  33. <?php the_excerpt( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?>
  34. </div><!-- .entry-summary -->
  35. <?php else : ?>
  36. <div class="entry-content">
  37. <?php if ( post_password_required() ) : ?>
  38. <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?>
  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. <figure class="gallery-thumb">
  48. <a href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
  49. </figure><!-- .gallery-thumb -->
  50. <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, 'twentyeleven' ),
  51. 'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"',
  52. number_format_i18n( $total_images )
  53. ); ?></em></p>
  54. <?php endif; ?>
  55. <?php the_excerpt(); ?>
  56. <?php endif; ?>
  57. <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyeleven' ), 'after' => '</div>' ) ); ?>
  58. </div><!-- .entry-content -->
  59. <?php endif; ?>
  60. <footer class="entry-meta">
  61. <span class="cat-links"><span class="entry-utility-prep entry-utility-prep-cat-links"><?php _e( 'Posted in', 'twentyeleven' ); ?></span> <?php the_category( ', ' ); ?></span>
  62. <?php the_tags( '<span class="sep"> | </span> <span class="tag-links"><span class="entry-utility-prep entry-utility-prep-tag-links">' . __( 'Tagged', 'twentyeleven' ) . '</span> ', ', ', '</span>' ); ?>
  63. <?php if ( comments_open() ) : ?>
  64. <span class="sep"> | </span>
  65. <span class="comments-link"><?php comments_popup_link( __( '<span class="leave-reply">Leave a reply</span>', 'twentyeleven' ), __( '<b>1</b> Reply', 'twentyeleven' ), __( '<b>%</b> Replies', 'twentyeleven' ) ); ?></span>
  66. <?php endif; ?>
  67. <?php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?>
  68. </footer><!-- #entry-meta -->
  69. </article><!-- #post-<?php the_ID(); ?> -->