search.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_Twenty_One
  9. * @since Twenty Twenty-One 1.0
  10. */
  11. get_header();
  12. if ( have_posts() ) {
  13. ?>
  14. <header class="page-header alignwide">
  15. <h1 class="page-title">
  16. <?php
  17. printf(
  18. /* translators: %s: Search term. */
  19. esc_html__( 'Results for "%s"', 'twentytwentyone' ),
  20. '<span class="page-description search-term">' . esc_html( get_search_query() ) . '</span>'
  21. );
  22. ?>
  23. </h1>
  24. </header><!-- .page-header -->
  25. <div class="search-result-count default-max-width">
  26. <?php
  27. printf(
  28. esc_html(
  29. /* translators: %d: The number of search results. */
  30. _n(
  31. 'We found %d result for your search.',
  32. 'We found %d results for your search.',
  33. (int) $wp_query->found_posts,
  34. 'twentytwentyone'
  35. )
  36. ),
  37. (int) $wp_query->found_posts
  38. );
  39. ?>
  40. </div><!-- .search-result-count -->
  41. <?php
  42. // Start the Loop.
  43. while ( have_posts() ) {
  44. the_post();
  45. /*
  46. * Include the Post-Format-specific template for the content.
  47. * If you want to override this in a child theme, then include a file
  48. * called content-___.php (where ___ is the Post Format name) and that will be used instead.
  49. */
  50. get_template_part( 'template-parts/content/content-excerpt', get_post_format() );
  51. } // End the loop.
  52. // Previous/next page navigation.
  53. twenty_twenty_one_the_posts_navigation();
  54. // If no content, include the "No posts found" template.
  55. } else {
  56. get_template_part( 'template-parts/content/content-none' );
  57. }
  58. get_footer();