Sin descripción

index.php 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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_archive() && ! have_posts() ) {
  44. $archive_title = __( 'Nothing Found', 'twentytwenty' );
  45. } elseif ( ! is_home() ) {
  46. $archive_title = get_the_archive_title();
  47. $archive_subtitle = get_the_archive_description();
  48. }
  49. if ( $archive_title || $archive_subtitle ) {
  50. ?>
  51. <header class="archive-header has-text-align-center header-footer-group">
  52. <div class="archive-header-inner section-inner medium">
  53. <?php if ( $archive_title ) { ?>
  54. <h1 class="archive-title"><?php echo wp_kses_post( $archive_title ); ?></h1>
  55. <?php } ?>
  56. <?php if ( $archive_subtitle ) { ?>
  57. <div class="archive-subtitle section-inner thin max-percentage intro-text"><?php echo wp_kses_post( wpautop( $archive_subtitle ) ); ?></div>
  58. <?php } ?>
  59. </div><!-- .archive-header-inner -->
  60. </header><!-- .archive-header -->
  61. <?php
  62. }
  63. if ( have_posts() ) {
  64. $i = 0;
  65. while ( have_posts() ) {
  66. $i++;
  67. if ( $i > 1 ) {
  68. echo '<hr class="post-separator styled-separator is-style-wide section-inner" aria-hidden="true" />';
  69. }
  70. the_post();
  71. get_template_part( 'template-parts/content', get_post_type() );
  72. }
  73. } elseif ( is_search() ) {
  74. ?>
  75. <div class="no-search-results-form section-inner thin">
  76. <?php
  77. get_search_form(
  78. array(
  79. 'aria_label' => __( 'search again', 'twentytwenty' ),
  80. )
  81. );
  82. ?>
  83. </div><!-- .no-search-results -->
  84. <?php
  85. }
  86. ?>
  87. <?php get_template_part( 'template-parts/pagination' ); ?>
  88. </main><!-- #site-content -->
  89. <?php get_template_part( 'template-parts/footer-menus-widgets' ); ?>
  90. <?php
  91. get_footer();