search.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * The template for displaying search results pages
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#search-result
  6. *
  7. * @package WordPress
  8. * @subpackage Twenty_Seventeen
  9. * @since 1.0
  10. * @version 1.0
  11. */
  12. get_header(); ?>
  13. <div class="wrap">
  14. <header class="page-header">
  15. <?php if ( have_posts() ) : ?>
  16. <h1 class="page-title">
  17. <?php
  18. /* translators: Search query. */
  19. printf( __( 'Search Results for: %s', 'twentyseventeen' ), '<span>' . get_search_query() . '</span>' );
  20. ?>
  21. </h1>
  22. <?php else : ?>
  23. <h1 class="page-title"><?php _e( 'Nothing Found', 'twentyseventeen' ); ?></h1>
  24. <?php endif; ?>
  25. </header><!-- .page-header -->
  26. <div id="primary" class="content-area">
  27. <main id="main" class="site-main" role="main">
  28. <?php
  29. if ( have_posts() ) :
  30. /* Start the Loop */
  31. while ( have_posts() ) :
  32. the_post();
  33. /**
  34. * Run the loop for the search to output the results.
  35. * If you want to overload this in a child theme then include a file
  36. * called content-search.php and that will be used instead.
  37. */
  38. get_template_part( 'template-parts/post/content', 'excerpt' );
  39. endwhile; // End of the loop.
  40. the_posts_pagination(
  41. array(
  42. 'prev_text' => twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '<span class="screen-reader-text">' . __( 'Previous page', 'twentyseventeen' ) . '</span>',
  43. 'next_text' => '<span class="screen-reader-text">' . __( 'Next page', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ),
  44. 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyseventeen' ) . ' </span>',
  45. )
  46. );
  47. else :
  48. ?>
  49. <p><?php _e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'twentyseventeen' ); ?></p>
  50. <?php
  51. get_search_form();
  52. endif;
  53. ?>
  54. </main><!-- #main -->
  55. </div><!-- #primary -->
  56. <?php get_sidebar(); ?>
  57. </div><!-- .wrap -->
  58. <?php
  59. get_footer();