[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-content/themes/twentytwenty/ -> index.php (source)

   1  <?php
   2  /**
   3   * The main template file
   4   *
   5   * This is the most generic template file in a WordPress theme
   6   * and one of the two required files for a theme (the other being style.css).
   7   * It is used to display a page when nothing more specific matches a query.
   8   * E.g., it puts together the home page when no home.php file exists.
   9   *
  10   * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
  11   *
  12   * @package WordPress
  13   * @subpackage Twenty_Twenty
  14   * @since Twenty Twenty 1.0
  15   */
  16  
  17  get_header();
  18  ?>
  19  
  20  <main id="site-content" role="main">
  21  
  22      <?php
  23  
  24      $archive_title    = '';
  25      $archive_subtitle = '';
  26  
  27      if ( is_search() ) {
  28          global $wp_query;
  29  
  30          $archive_title = sprintf(
  31              '%1$s %2$s',
  32              '<span class="color-accent">' . __( 'Search:', 'twentytwenty' ) . '</span>',
  33              '&ldquo;' . get_search_query() . '&rdquo;'
  34          );
  35  
  36          if ( $wp_query->found_posts ) {
  37              $archive_subtitle = sprintf(
  38                  /* translators: %s: Number of search results */
  39                  _n(
  40                      'We found %s result for your search.',
  41                      'We found %s results for your search.',
  42                      $wp_query->found_posts,
  43                      'twentytwenty'
  44                  ),
  45                  number_format_i18n( $wp_query->found_posts )
  46              );
  47          } else {
  48              $archive_subtitle = __( 'We could not find any results for your search. You can give it another try through the search form below.', 'twentytwenty' );
  49          }
  50      } elseif ( ! is_home() ) {
  51          $archive_title    = get_the_archive_title();
  52          $archive_subtitle = get_the_archive_description();
  53      }
  54  
  55      if ( $archive_title || $archive_subtitle ) {
  56          ?>
  57  
  58          <header class="archive-header has-text-align-center header-footer-group">
  59  
  60              <div class="archive-header-inner section-inner medium">
  61  
  62                  <?php if ( $archive_title ) { ?>
  63                      <h1 class="archive-title"><?php echo wp_kses_post( $archive_title ); ?></h1>
  64                  <?php } ?>
  65  
  66                  <?php if ( $archive_subtitle ) { ?>
  67                      <div class="archive-subtitle section-inner thin max-percentage intro-text"><?php echo wp_kses_post( wpautop( $archive_subtitle ) ); ?></div>
  68                  <?php } ?>
  69  
  70              </div><!-- .archive-header-inner -->
  71  
  72          </header><!-- .archive-header -->
  73  
  74          <?php
  75      }
  76  
  77      if ( have_posts() ) {
  78  
  79          $i = 0;
  80  
  81          while ( have_posts() ) {
  82              $i++;
  83              if ( $i > 1 ) {
  84                  echo '<hr class="post-separator styled-separator is-style-wide section-inner" aria-hidden="true" />';
  85              }
  86              the_post();
  87  
  88              get_template_part( 'template-parts/content', get_post_type() );
  89  
  90          }
  91      } elseif ( is_search() ) {
  92          ?>
  93  
  94          <div class="no-search-results-form section-inner thin">
  95  
  96              <?php
  97              get_search_form(
  98                  array(
  99                      'label' => __( 'search again', 'twentytwenty' ),
 100                  )
 101              );
 102              ?>
 103  
 104          </div><!-- .no-search-results -->
 105  
 106          <?php
 107      }
 108      ?>
 109  
 110      <?php get_template_part( 'template-parts/pagination' ); ?>
 111  
 112  </main><!-- #site-content -->
 113  
 114  <?php get_template_part( 'template-parts/footer-menus-widgets' ); ?>
 115  
 116  <?php
 117  get_footer();


Generated: Fri Dec 13 01:00:03 2019 Cross-referenced by PHPXref 0.7.1