PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/loop.php

https://github.com/monfresh/cfawp2012
PHP | 160 lines | 108 code | 21 blank | 31 comment | 13 complexity | 13f9638c86acb5a58d14d59a25953176 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0
  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. * @package WordPress
  17. * @subpackage Twenty_Ten
  18. * @since Twenty Ten 1.0
  19. */
  20. ?>
  21. <div id="posts">
  22. <div id="cfa-blog" class="wrap">
  23. <?php /* Display navigation to next/previous pages when applicable */ ?>
  24. <!--<?php if ( $wp_query->max_num_pages > 1 ) : ?>
  25. <div id="nav-above" class="navigation">
  26. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
  27. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
  28. </div>
  29. <?php endif; ?>-->
  30. <?php /* If there are no posts to display, such as an empty archive page */ ?>
  31. <?php if ( ! have_posts() ) : ?>
  32. <div id="post-0" class="post error404 not-found">
  33. <h1 class="entry-title"><?php _e( 'Not Found', 'twentyten' ); ?></h1>
  34. <div class="entry-content">
  35. <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyten' ); ?></p>
  36. <?php get_search_form(); ?>
  37. </div><!-- .entry-content -->
  38. </div><!-- #post-0 -->
  39. <?php endif; ?>
  40. <?php
  41. /* Start the Loop.
  42. *
  43. * In Twenty Ten we use the same loop in multiple contexts.
  44. * It is broken into three main parts: when we're displaying
  45. * posts that are in the gallery category, when we're displaying
  46. * posts in the asides category, and finally all other posts.
  47. *
  48. * Additionally, we sometimes check for whether we are on an
  49. * archive page, a search page, etc., allowing for small differences
  50. * in the loop on each template without actually duplicating
  51. * the rest of the loop that is shared.
  52. *
  53. * Without further ado, the loop:
  54. */ ?>
  55. <?php while ( have_posts() ) : the_post(); ?>
  56. <?php /* How to display posts in the Gallery category. */ ?>
  57. <?php if ( in_category( _x('gallery', 'gallery category slug', 'twentyten') ) ) : ?>
  58. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  59. <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>
  60. <div class="entry-meta">
  61. <?php twentyten_posted_on(); ?>
  62. </div><!-- .entry-meta -->
  63. <div class="entry-content">
  64. <?php if ( post_password_required() ) : ?>
  65. <?php the_excerpt(); ?>
  66. <?php else : ?>
  67. <?php
  68. $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
  69. if ( $images ) :
  70. $total_images = count( $images );
  71. $image = array_shift( $images );
  72. $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
  73. ?>
  74. <div class="gallery-thumb">
  75. <a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
  76. </div><!-- .gallery-thumb -->
  77. <p><em><?php printf( __( 'This gallery contains <a %1$s>%2$s photos</a>.', 'twentyten' ),
  78. 'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"',
  79. $total_images
  80. ); ?></em></p>
  81. <?php endif; ?>
  82. <?php the_excerpt(); ?>
  83. <?php endif; ?>
  84. </div><!-- .entry-content -->
  85. <div class="entry-utility">
  86. <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>
  87. <span class="meta-sep">|</span>
  88. <span class="comments-link"><?php comments_popup_link( __( 'Comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
  89. <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
  90. </div><!-- .entry-utility -->
  91. </div><!-- #post-## -->
  92. <?php /* How to display posts in the asides category */ ?>
  93. <?php elseif ( in_category( _x('asides', 'asides category slug', 'twentyten') ) ) : ?>
  94. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  95. <?php if ( is_archive() || is_search() ) : // Display excerpts for archives and search. ?>
  96. <div class="entry-summary">
  97. <?php the_excerpt(); ?>
  98. </div><!-- .entry-summary -->
  99. <?php else : ?>
  100. <div class="entry-content">
  101. <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
  102. </div><!-- .entry-content -->
  103. <?php endif; ?>
  104. <div class="entry-utility">
  105. <?php twentyten_posted_on(); ?>
  106. <span class="meta-sep">|</span>
  107. <span class="comments-link"><?php comments_popup_link( __( 'Comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
  108. <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
  109. </div><!-- .entry-utility -->
  110. </div><!-- #post-## -->
  111. <?php /* How to display all other posts. */ ?>
  112. <?php else : ?>
  113. <div id="post" class="loop-post">
  114. <h2 class=""><div style="float: right; margin-left: 10px;"> <?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'twentyten_author_bio_avatar_size', 40 ) ); ?></div><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>
  115. <p class="date"><?php twentyten_posted_on(); ?> <?php twentyten_posted_in(); ?></p>
  116. <div style="float: left; margin-bottom: 30px;"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail('thumbnail'); ?></div> <div class="post" style="<?php
  117. if (has_post_thumbnail()) {
  118. echo 'margin-left: 180px';
  119. };
  120. ?> " ></a>
  121. <?php the_excerpt('',FALSE,''); ?>
  122. <ul>
  123. <li>Share: <a href="#" class="like-btn st_email_custom" id="mail-b">E-mail</a> <a href="<?php the_permalink(); ?>/feed" class="like-btn" id="rss-b">RSS</a> <a href="#" class="like-btn st_facebook_custom" id="fb-b"">Facebook</a> <a href="#" class="like-btn st_twitter_custom" id="tw-b">Twitter</a></li>
  124. <li><?php comments_popup_link( __( 'Comment', 'twentyten' ), __( 'Comment (1)', 'twentyten' ), __( 'Comments (%)', 'twentyten' ), 'comments' ); ?></li>
  125. <li class="right"><a class="more" href="<?php the_permalink(); ?>">Read More</a></li>
  126. </ul>
  127. </div>
  128. </div><!-- #post-## -->
  129. <?php comments_template( '', true ); ?>
  130. <?php endif; // This was the if statement that broke the loop into three parts based on categories. ?>
  131. <?php endwhile; // End the loop. Whew. ?>
  132. <?php /* Display navigation to next/previous pages when applicable */ ?>
  133. <?php if ( $wp_query->max_num_pages > 1 ) : ?>
  134. <div id="nav-below" class="navigation">
  135. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
  136. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
  137. </div><!-- #nav-below -->
  138. <?php endif; ?>
  139. </div></div>