index.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. get_header();
  17. ?>
  18. <main id="site-content" role="main">
  19. <?php
  20. $archive_title = '';
  21. $archive_subtitle = '';
  22. if ( is_search() ) {
  23. global $wp_query;
  24. $archive_title = sprintf(
  25. '%1$s %2$s',
  26. '<span class="color-accent">' . __( 'Search:', 'twentytwenty' ) . '</span>',
  27. '&ldquo;' . get_search_query() . '&rdquo;'
  28. );
  29. if ( $wp_query->found_posts ) {
  30. $archive_subtitle = sprintf(
  31. /* translators: %s: Number of search results. */
  32. _n(
  33. 'We found %s result for your search.',
  34. 'We found %s results for your search.',
  35. $wp_query->found_posts,
  36. 'twentytwenty'
  37. ),
  38. number_format_i18n( $wp_query->found_posts )
  39. );
  40. } else {
  41. $archive_subtitle = __( 'We could not find any results for your search. You can give it another try through the search form below.', 'twentytwenty' );
  42. }
  43. } elseif ( ! is_home() ) {
  44. $archive_title = get_the_archive_title();
  45. $archive_subtitle = get_the_archive_description();
  46. }
  47. if ( $archive_title || $archive_subtitle ) {
  48. ?>
  49. <header class="archive-header has-text-align-center header-footer-group">
  50. <div class="archive-header-inner section-inner medium">
  51. <?php if ( $archive_title ) { ?>
  52. <h1 class="archive-title"><?php echo wp_kses_post( $archive_title ); ?></h1>
  53. <?php } ?>
  54. <?php if ( $archive_subtitle ) { ?>
  55. <div class="archive-subtitle section-inner thin max-percentage intro-text"><?php echo wp_kses_post( wpautop( $archive_subtitle ) ); ?></div>
  56. <?php } ?>
  57. </div><!-- .archive-header-inner -->
  58. </header><!-- .archive-header -->
  59. <?php
  60. }
  61. if ( have_posts() ) {
  62. $i = 0;
  63. while ( have_posts() ) {
  64. $i++;
  65. if ( $i > 1 ) {
  66. echo '<hr class="post-separator styled-separator is-style-wide section-inner" aria-hidden="true" />';
  67. }
  68. the_post();
  69. get_template_part( 'template-parts/content', get_post_type() );
  70. }
  71. } elseif ( is_search() ) {
  72. ?>
  73. <div class="no-search-results-form section-inner thin">
  74. <?php
  75. get_search_form(
  76. array(
  77. 'label' => __( 'search again', 'twentytwenty' ),
  78. )
  79. );
  80. ?>
  81. </div><!-- .no-search-results -->
  82. <?php
  83. }
  84. ?>
  85. <?php get_template_part( 'template-parts/pagination' ); ?>
  86. </main><!-- #site-content -->
  87. <?php get_template_part( 'template-parts/footer-menus-widgets' ); ?>
  88. <?php
  89. get_footer();