[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-content/themes/twentytwentyone/ -> search.php (source)

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


Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref