PageRenderTime 55ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/loop.php

https://github.com/fprestes/Conde-WordPress-Theme
PHP | 130 lines | 75 code | 24 blank | 31 comment | 17 complexity | 4f7ab21f44d9f4d36654e1a918a58e87 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. * @package WordPress
  17. * @subpackage Foursquare Two
  18. * @since Foursquare Two 1.0
  19. */
  20. ?>
  21. <!--<?php /* Display navigation to next/previous pages when applicable */ ?>
  22. <?php if ( $wp_query->max_num_pages > 1 ) : ?>
  23. <?php next_posts_link( __( '&larr; Older posts', 'twentyten' ) ); ?>
  24. <?php previous_posts_link( __( 'Newer posts &rarr;', 'twentyten' ) ); ?>
  25. <?php endif; ?>-->
  26. <?php /* If there are no posts to display, such as an empty archive page */ ?>
  27. <?php if ( ! have_posts() ) : ?>
  28. <h1><?php _e( 'Not Found', 'twentyten' ); ?></h1>
  29. <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyten' ); ?></p>
  30. <?php get_search_form(); ?>
  31. <?php endif; ?>
  32. <?php
  33. /* Start the Loop.
  34. *
  35. * In Twenty Ten we use the same loop in multiple contexts.
  36. * It is broken into three main parts: when we're displaying
  37. * posts that are in the gallery category, when we're displaying
  38. * posts in the asides category, and finally all other posts.
  39. *
  40. * Additionally, we sometimes check for whether we are on an
  41. * archive page, a search page, etc., allowing for small differences
  42. * in the loop on each template without actually duplicating
  43. * the rest of the loop that is shared.
  44. *
  45. * Without further ado, the loop:
  46. */ ?>
  47. <?php while ( have_posts() ) : the_post(); ?>
  48. <?php /* How to display posts in the Gallery category. */ ?>
  49. <?php if ( in_category( _x('gallery', 'gallery category slug', 'twentyten') ) ) : ?>
  50. <h1><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></h1>
  51. <?php twentyten_posted_on(); ?>
  52. <?php if ( post_password_required() ) : ?>
  53. <?php the_content(); ?>
  54. <?php else : ?>
  55. <?php
  56. $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
  57. $total_images = count( $images );
  58. $image = array_shift( $images );
  59. $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
  60. ?>
  61. <a href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
  62. <p><?php printf( __( 'This gallery contains <a %1$s>%2$s photos</a>.', 'twentyten' ),
  63. 'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"',
  64. $total_images
  65. ); ?></p>
  66. <?php the_excerpt(); ?>
  67. <?php endif; ?>
  68. <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>
  69. |
  70. <?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?>
  71. <?php edit_post_link( __( 'Edit', 'twentyten' ), '|', '' ); ?>
  72. <?php /* How to display posts in the asides category */ ?>
  73. <?php elseif ( in_category( _x('asides', 'asides category slug', 'twentyten') ) ) : ?>
  74. <?php if ( is_archive() || is_search() ) : // Display excerpts for archives and search. ?>
  75. <?php the_excerpt(); ?>
  76. <?php else : ?>
  77. <?php the_content( __( 'More', 'twentyten' ) ); ?>
  78. <?php endif; ?>
  79. <?php twentyten_posted_on(); ?>
  80. |
  81. <?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?>
  82. <?php edit_post_link( __( 'Edit', 'twentyten' ), '| ', '' ); ?>
  83. <?php /* How to display all other posts. */ ?>
  84. <?php else : ?>
  85. <h1><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></h1>
  86. <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) { the_post_thumbnail(array(200,160), array("class" => "alignleft post_thumbnail")); } ?>
  87. <p class="meta"><?php twentyten_posted_on(); ?></p>
  88. <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
  89. <?php the_excerpt(); ?>
  90. <?php else : ?>
  91. <?php the_excerpt('More'); ?>
  92. <?php wp_link_pages( array( 'before' => '' . __( 'Pages:', 'twentyten' ), 'after' => '' ) ); ?>
  93. <?php endif; ?>
  94. <?php if ( count( get_the_category() ) ) : ?>
  95. <?php printf( __( 'Posted in %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
  96. <?php endif; ?>
  97. <?php edit_post_link( __( '(Edit Post)', 'twentyten' ), '', '' ); ?>
  98. <p><hr /></p>
  99. <?php comments_template( '', true ); ?>
  100. <?php endif; // This was the if statement that broke the loop into three parts based on categories. ?>
  101. <?php endwhile; // End the loop. Whew. ?>
  102. <?php /* Display navigation to next/previous pages when applicable */ ?>
  103. <?php if ( $wp_query->max_num_pages > 1 ) : ?>
  104. <p class="bottom-nav left"><?php next_posts_link( __( 'ÂŤ Older posts', 'twentyten' ) ); ?></p>
  105. <p class="bottom-nav right"><?php previous_posts_link( __( 'Newer posts Âť', 'twentyten' ) ); ?></p>
  106. <?php endif; ?>