[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
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"> 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 '“' . get_search_query() . '”' 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_archive() && ! have_posts() ) { 51 $archive_title = __( 'Nothing Found', 'twentytwenty' ); 52 } elseif ( ! is_home() ) { 53 $archive_title = get_the_archive_title(); 54 $archive_subtitle = get_the_archive_description(); 55 } 56 57 if ( $archive_title || $archive_subtitle ) { 58 ?> 59 60 <header class="archive-header has-text-align-center header-footer-group"> 61 62 <div class="archive-header-inner section-inner medium"> 63 64 <?php if ( $archive_title ) { ?> 65 <h1 class="archive-title"><?php echo wp_kses_post( $archive_title ); ?></h1> 66 <?php } ?> 67 68 <?php if ( $archive_subtitle ) { ?> 69 <div class="archive-subtitle section-inner thin max-percentage intro-text"><?php echo wp_kses_post( wpautop( $archive_subtitle ) ); ?></div> 70 <?php } ?> 71 72 </div><!-- .archive-header-inner --> 73 74 </header><!-- .archive-header --> 75 76 <?php 77 } 78 79 if ( have_posts() ) { 80 81 $i = 0; 82 83 while ( have_posts() ) { 84 $i++; 85 if ( $i > 1 ) { 86 echo '<hr class="post-separator styled-separator is-style-wide section-inner" aria-hidden="true" />'; 87 } 88 the_post(); 89 90 get_template_part( 'template-parts/content', get_post_type() ); 91 92 } 93 } elseif ( is_search() ) { 94 ?> 95 96 <div class="no-search-results-form section-inner thin"> 97 98 <?php 99 get_search_form( 100 array( 101 'aria_label' => __( 'search again', 'twentytwenty' ), 102 ) 103 ); 104 ?> 105 106 </div><!-- .no-search-results --> 107 108 <?php 109 } 110 ?> 111 112 <?php get_template_part( 'template-parts/pagination' ); ?> 113 114 </main><!-- #site-content --> 115 116 <?php get_template_part( 'template-parts/footer-menus-widgets' ); ?> 117 118 <?php 119 get_footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:00:03 2024 | Cross-referenced by PHPXref 0.7.1 |