[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-content/themes/twentyseventeen/ -> 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_Seventeen
   9   * @since Twenty Seventeen 1.0
  10   * @version 1.0
  11   */
  12  
  13  get_header(); ?>
  14  
  15  <div class="wrap">
  16  
  17      <header class="page-header">
  18          <?php if ( have_posts() ) : ?>
  19              <h1 class="page-title">
  20              <?php
  21              /* translators: Search query. */
  22              printf( __( 'Search Results for: %s', 'twentyseventeen' ), '<span>' . get_search_query() . '</span>' );
  23              ?>
  24              </h1>
  25          <?php else : ?>
  26              <h1 class="page-title"><?php _e( 'Nothing Found', 'twentyseventeen' ); ?></h1>
  27          <?php endif; ?>
  28      </header><!-- .page-header -->
  29  
  30      <div id="primary" class="content-area">
  31          <main id="main" class="site-main">
  32  
  33          <?php
  34          if ( have_posts() ) :
  35              // Start the Loop.
  36              while ( have_posts() ) :
  37                  the_post();
  38  
  39                  /**
  40                   * Run the loop for the search to output the results.
  41                   * If you want to overload this in a child theme then include a file
  42                   * called content-search.php and that will be used instead.
  43                   */
  44                  get_template_part( 'template-parts/post/content', 'excerpt' );
  45  
  46              endwhile; // End the loop.
  47  
  48              the_posts_pagination(
  49                  array(
  50                      'prev_text'          => twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '<span class="screen-reader-text">' . __( 'Previous page', 'twentyseventeen' ) . '</span>',
  51                      'next_text'          => '<span class="screen-reader-text">' . __( 'Next page', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ),
  52                      'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyseventeen' ) . ' </span>',
  53                  )
  54              );
  55  
  56          else :
  57              ?>
  58  
  59              <p><?php _e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'twentyseventeen' ); ?></p>
  60              <?php
  61                  get_search_form();
  62  
  63          endif;
  64          ?>
  65  
  66          </main><!-- #main -->
  67      </div><!-- #primary -->
  68      <?php get_sidebar(); ?>
  69  </div><!-- .wrap -->
  70  
  71  <?php
  72  get_footer();


Generated: Thu Nov 21 01:00:03 2024 Cross-referenced by PHPXref 0.7.1