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

/Starkers/loop-search.php

https://github.com/aspaceafo/aspace-theme
PHP | 148 lines | 87 code | 28 blank | 33 comment | 16 complexity | 4457a82cc1cd0e3b39572962a89bedb2 MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /**
  3. * The loop that displays search.
  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 Starkers
  18. * @since Starkers 3.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. <div class="page">
  29. <h1><?php _e( 'Not Found', 'twentyten' ); ?></h1>
  30. <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyten' ); ?></p>
  31. <?php get_search_form(); ?>
  32. </div>
  33. <?php endif; ?>
  34. <?php
  35. /* Start the Loop.
  36. *
  37. * In Twenty Ten we use the same loop in multiple contexts.
  38. * It is broken into three main parts: when we're displaying
  39. * posts that are in the gallery category, when we're displaying
  40. * posts in the asides category, and finally all other posts.
  41. *
  42. * Additionally, we sometimes check for whether we are on an
  43. * archive page, a search page, etc., allowing for small differences
  44. * in the loop on each template without actually duplicating
  45. * the rest of the loop that is shared.
  46. *
  47. * Without further ado, the loop:
  48. */ ?>
  49. <?php while ( have_posts() ) : the_post(); ?>
  50. <?php /* How to display posts in the Gallery category. */ ?>
  51. <?php if ( in_category( _x('gallery', 'gallery category slug', 'twentyten') ) ) : ?>
  52. <h2><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>
  53. <?php twentyten_posted_on(); ?>
  54. <?php if ( post_password_required() ) : ?>
  55. <?php the_content(); ?>
  56. <?php else : ?>
  57. <?php
  58. $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
  59. $total_images = count( $images );
  60. $image = array_shift( $images );
  61. $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
  62. ?>
  63. <a href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
  64. <p><?php printf( __( 'This gallery contains <a %1$s>%2$s photos</a>.', 'twentyten' ),
  65. 'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"',
  66. $total_images
  67. ); ?></p>
  68. <?php the_excerpt(); ?>
  69. <?php endif; ?>
  70. <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>
  71. |
  72. <?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?>
  73. <?php edit_post_link( __( 'Edit', 'twentyten' ), '|', '' ); ?>
  74. <?php /* How to display posts in the asides category */ ?>
  75. <?php elseif ( in_category( _x('asides', 'asides category slug', 'twentyten') ) ) : ?>
  76. SEARCH 1
  77. <?php if ( is_archive() || is_search() ) : // Display excerpts for archives and search. ?>
  78. <?php the_excerpt(); ?>
  79. <?php else : ?>
  80. <?php the_content( __( 'Continue reading &rarr;', 'twentyten' ) ); ?>
  81. <?php endif; ?>
  82. <?php twentyten_posted_on(); ?>
  83. |
  84. <?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?>
  85. <?php edit_post_link( __( 'Edit', 'twentyten' ), '| ', '' ); ?>
  86. <?php /* How to display all other posts. */ ?>
  87. <?php else : ?>
  88. <h2><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>
  89. <?php
  90. /* Searching through the archives yields this
  91. ** not used ** twentyten_posted_on();
  92. */?>
  93. <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
  94. <?php the_excerpt(); ?>
  95. <?php echo get_the_title($post->post_parent); ?>
  96. <?php else : ?>
  97. <?php the_content( __( 'Continue reading &rarr;', 'twentyten' ) ); ?>
  98. <?php wp_link_pages( array( 'before' => '' . __( 'Pages:', 'twentyten' ), 'after' => '' ) ); ?>
  99. <?php endif; ?>
  100. <?php if ( count( get_the_category() ) ) : ?>
  101. <?php printf( __( 'Posted in %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
  102. |
  103. <?php endif; ?>
  104. <?php
  105. $tags_list = get_the_tag_list( '', ', ' );
  106. if ( $tags_list ):
  107. ?>
  108. <?php printf( __( 'Tagged %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
  109. |
  110. <?php endif; ?>
  111. <?php // comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?>
  112. <?php edit_post_link( __( 'Edit', 'twentyten' ), '', '' ); ?>
  113. <?php comments_template( '', true ); ?>
  114. <?php endif; // This was the if statement that broke the loop into three parts based on categories. ?>
  115. <?php endwhile; // End the loop. Whew. ?>
  116. <?php /* Display navigation to next/previous pages when applicable */ ?>
  117. <?php if ( $wp_query->max_num_pages > 1 ) : ?>
  118. <?php next_posts_link( __( '&larr; Older posts', 'twentyten' ) ); ?>
  119. <?php previous_posts_link( __( 'Newer posts &rarr;', 'twentyten' ) ); ?>
  120. <?php endif; ?>