search.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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"><?php printf( __( 'Search Results for: %s', 'twentyseventeen' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
  17. <?php else : ?>
  18. <h1 class="page-title"><?php _e( 'Nothing Found', 'twentyseventeen' ); ?></h1>
  19. <?php endif; ?>
  20. </header><!-- .page-header -->
  21. <div id="primary" class="content-area">
  22. <main id="main" class="site-main" role="main">
  23. <?php
  24. if ( have_posts() ) :
  25. /* Start the Loop */
  26. while ( have_posts() ) : the_post();
  27. /**
  28. * Run the loop for the search to output the results.
  29. * If you want to overload this in a child theme then include a file
  30. * called content-search.php and that will be used instead.
  31. */
  32. get_template_part( 'template-parts/post/content', 'excerpt' );
  33. endwhile; // End of the loop.
  34. the_posts_pagination( array(
  35. 'prev_text' => twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '<span class="screen-reader-text">' . __( 'Previous page', 'twentyseventeen' ) . '</span>',
  36. 'next_text' => '<span class="screen-reader-text">' . __( 'Next page', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ),
  37. 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyseventeen' ) . ' </span>',
  38. ) );
  39. else : ?>
  40. <p><?php _e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'twentyseventeen' ); ?></p>
  41. <?php
  42. get_search_form();
  43. endif;
  44. ?>
  45. </main><!-- #main -->
  46. </div><!-- #primary -->
  47. <?php get_sidebar(); ?>
  48. </div><!-- .wrap -->
  49. <?php get_footer();