PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/wakeup/loop-author.php

https://github.com/sharpmachine/wakeupmedia.com
PHP | 193 lines | 139 code | 26 blank | 28 comment | 28 complexity | c081129dc631a5ae03e9d768d4377d69 MD5 | raw file
  1. <?php
  2. /**
  3. * The loop that displays posts.
  4. *
  5. * The loop displays the posts and the post content. See
  6. * http://codex.wordpress.org/The_Loop to understand it and
  7. * http://codex.wordpress.org/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. */
  17. ?>
  18. <?php /* Display navigation to next/previous pages when applicable */ ?>
  19. <?php /* If there are no posts to display, such as an empty archive page */ ?>
  20. <?php
  21. global $wp_query, $wp_rewrite;
  22. $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
  23. $pagination = array(
  24. 'base' => @add_query_arg('page','%#%'),
  25. 'format' => '',
  26. 'total' => $wp_query->max_num_pages,
  27. 'current' => $current,
  28. 'show_all' => true,
  29. 'type' => 'plain'
  30. );
  31. if( $wp_rewrite->using_permalinks() ) $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );
  32. if( !empty($wp_query->query_vars['s']) ) $pagination['add_args'] = array( 's' => get_query_var( 's' ) );
  33. ?>
  34. <?php if ( ! have_posts() ) : ?>
  35. <div id="post-0" class="post error404 not-found">
  36. <h1 class="entry-title"><?php _e( 'Not Found', 'twentyten' ); ?></h1>
  37. <div class="entry-content">
  38. <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyten' ); ?></p>
  39. <?php get_search_form(); ?>
  40. </div><!-- .entry-content -->
  41. </div><!-- #post-0 -->
  42. <?php endif; ?>
  43. <?php
  44. /* Start the Loop.
  45. *
  46. * In Twenty Ten we use the same loop in multiple contexts.
  47. * It is broken into three main parts: when we're displaying
  48. * posts that are in the gallery category, when we're displaying
  49. * posts in the asides category, and finally all other posts.
  50. *
  51. * Additionally, we sometimes check for whether we are on an
  52. * archive page, a search page, etc., allowing for small differences
  53. * in the loop on each template without actually duplicating
  54. * the rest of the loop that is shared.
  55. *
  56. * Without further ado, the loop:
  57. */ ?>
  58. <?php while ( have_posts() ) : the_post(); ?>
  59. <?php /* How to display posts of the Gallery format. The gallery category is the old way. */ ?>
  60. <?php if ( ( function_exists( 'get_post_format' ) && 'gallery' == get_post_format( $post->ID ) ) || in_category( _x( 'gallery', 'gallery category slug', 'twentyten' ) ) ) : ?>
  61. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  62. <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  63. <div class="entry-meta">
  64. <?php twentyten_posted_on(); ?>
  65. </div><!-- .entry-meta -->
  66. <div class="entry-content">
  67. <?php if ( post_password_required() ) : ?>
  68. <?php the_content(); ?>
  69. <?php else : ?>
  70. <?php
  71. $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
  72. if ( $images ) :
  73. $total_images = count( $images );
  74. $image = array_shift( $images );
  75. $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
  76. ?>
  77. <div class="gallery-thumb">
  78. <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
  79. </div><!-- .gallery-thumb -->
  80. <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, 'twentyten' ),
  81. 'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"',
  82. number_format_i18n( $total_images )
  83. ); ?></em></p>
  84. <?php endif; ?>
  85. <?php the_excerpt(); ?>
  86. <?php endif; ?>
  87. </div><!-- .entry-content -->
  88. <div class="entry-utility">
  89. <?php if ( function_exists( 'get_post_format' ) && 'gallery' == get_post_format( $post->ID ) ) : ?>
  90. <a href="<?php echo get_post_format_link( 'gallery' ); ?>" title="<?php esc_attr_e( 'View Galleries', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a>
  91. <span class="meta-sep">|</span>
  92. <?php elseif ( in_category( _x( 'gallery', 'gallery category slug', 'twentyten' ) ) ) : ?>
  93. <a href="<?php echo get_term_link( _x( 'gallery', 'gallery category slug', 'twentyten' ), 'category' ); ?>" title="<?php esc_attr_e( 'View posts in the Gallery category', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a>
  94. <span class="meta-sep">|</span>
  95. <?php endif; ?>
  96. <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
  97. <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
  98. </div><!-- .entry-utility -->
  99. </div><!-- #post-## -->
  100. <?php /* How to display posts of the Aside format. The asides category is the old way. */ ?>
  101. <?php elseif ( ( function_exists( 'get_post_format' ) && 'aside' == get_post_format( $post->ID ) ) || in_category( _x( 'asides', 'asides category slug', 'twentyten' ) ) ) : ?>
  102. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  103. <?php if ( is_archive() || is_search() ) : // Display excerpts for archives and search. ?>
  104. <div class="entry-summary">
  105. <?php the_excerpt(); ?>
  106. </div><!-- .entry-summary -->
  107. <?php else : ?>
  108. <div class="entry-content">
  109. <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
  110. </div><!-- .entry-content -->
  111. <?php endif; ?>
  112. <div class="entry-utility">
  113. <?php twentyten_posted_on(); ?>
  114. <span class="meta-sep">|</span>
  115. <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
  116. <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
  117. </div><!-- .entry-utility -->
  118. </div><!-- #post-## -->
  119. <?php /* How to display all other posts. */ ?>
  120. <?php else : ?>
  121. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  122. <h2 class="entry-title wum-archives"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  123. <div class="entry-meta">
  124. <?php twentyten_posted_on(); ?>
  125. </div><!-- .entry-meta -->
  126. <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
  127. <div class="entry-summary">
  128. <?php the_excerpt(); ?>
  129. </div><!-- .entry-summary -->
  130. <?php else : ?>
  131. <div class="entry-content">
  132. <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
  133. <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
  134. </div><!-- .entry-content -->
  135. <?php endif; ?>
  136. <div class="entry-utility">
  137. <?php if ( count( get_the_category() ) ) : ?>
  138. <span class="cat-links">
  139. <?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
  140. </span>
  141. <span class="meta-sep">|</span>
  142. <?php endif; ?>
  143. <?php
  144. $tags_list = get_the_tag_list( '', ', ' );
  145. if ( $tags_list ):
  146. ?>
  147. <span class="tag-links">
  148. <?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
  149. </span>
  150. <span class="meta-sep">|</span>
  151. <?php endif; ?>
  152. <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
  153. <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
  154. </div><!-- .entry-utility -->
  155. </div><!-- #post-## -->
  156. <?php comments_template( '', true ); ?>
  157. <?php endif; // This was the if statement that broke the loop into three parts based on categories. ?>
  158. <?php endwhile; // End the loop. Whew. ?>
  159. <?php /* Display navigation to next/previous pages when applicable */ ?>
  160. <?php if ( $wp_query->max_num_pages > 1 ) : ?>
  161. <!-- WP-Pagination Plugin -->
  162. <div id="nav-below" class="navigation">
  163. <?php if(function_exists('wp_paginate')) {
  164. wp_paginate();
  165. } ?>
  166. </div><!-- #nav-below -->
  167. <?php endif; ?>