PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/themes/OneMozilla/search.php

https://github.com/fvignals/One-Mozilla-blog
PHP | 54 lines | 38 code | 15 blank | 1 comment | 9 complexity | e575501c5c7d67b811d195cc8437d3f1 MD5 | raw file
  1. <?php
  2. // Count search results
  3. global $wp_query;
  4. $total_results = $wp_query->found_posts;
  5. get_header(); ?>
  6. <div id="content-main" class="main" role="main">
  7. <?php if ( have_posts() ) : ?>
  8. <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
  9. <h1 class="page-title"><?php printf( _n('We found one result for “%2$s”', 'We found %1$s results for “%2$s”', $total_results, 'onemozilla'), $total_results, esc_html(get_search_query()) ); ?></h1>
  10. <?php if (fc_show_posts_nav()) : ?>
  11. <nav class="nav-paging top">
  12. <ul role="navigation">
  13. <?php if ( $paged < $wp_query->max_num_pages ) : ?><li class="prev"><?php next_posts_link(__('Older posts','onemozilla')); ?></li><?php endif; ?>
  14. <?php if ( $paged > 1 ) : ?><li class="next"><?php previous_posts_link(__('Newer posts','onemozilla')); ?></li><?php endif; ?>
  15. </ul>
  16. </nav>
  17. <?php endif; ?>
  18. <?php /* Start the Loop */ ?>
  19. <?php while ( have_posts() ) : the_post(); ?>
  20. <?php get_template_part( 'content', 'summary' ); ?>
  21. <?php endwhile; ?>
  22. <?php if (fc_show_posts_nav()) : ?>
  23. <nav class="nav-paging bottom">
  24. <ul role="navigation">
  25. <?php if ( $paged < $wp_query->max_num_pages ) : ?><li class="prev"><?php next_posts_link(__('Older posts','onemozilla')); ?></li><?php endif; ?>
  26. <?php if ( $paged > 1 ) : ?><li class="next"><?php previous_posts_link(__('Newer posts','onemozilla')); ?></li><?php endif; ?>
  27. </ul>
  28. </nav>
  29. <?php endif; ?>
  30. <?php else : ?>
  31. <h1 class="page-title"><?php _e( 'Nothing Found', 'onemozilla' ); ?></h1>
  32. <div class="entry-content">
  33. <p><?php printf( __( 'Sorry, we didn\'t find anything for “%s.” Try another search.', 'onemozilla' ), esc_html(get_search_query()) ); ?></p>
  34. <?php get_search_form(); ?>
  35. </div><!-- .entry-content -->
  36. <?php endif; ?>
  37. </div><!-- #content-main -->
  38. <?php get_sidebar(); ?>
  39. <?php get_footer(); ?>