[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[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 /** 29 * @global WP_Query $wp_query WordPress Query object. 30 */ 31 global $wp_query; 32 33 $archive_title = sprintf( 34 '%1$s %2$s', 35 '<span class="color-accent">' . __( 'Search:', 'twentytwenty' ) . '</span>', 36 '“' . get_search_query() . '”' 37 ); 38 39 if ( $wp_query->found_posts ) { 40 $archive_subtitle = sprintf( 41 /* translators: %s: Number of search results. */ 42 _n( 43 'We found %s result for your search.', 44 'We found %s results for your search.', 45 $wp_query->found_posts, 46 'twentytwenty' 47 ), 48 number_format_i18n( $wp_query->found_posts ) 49 ); 50 } else { 51 $archive_subtitle = __( 'We could not find any results for your search. You can give it another try through the search form below.', 'twentytwenty' ); 52 } 53 } elseif ( is_archive() && ! have_posts() ) { 54 $archive_title = __( 'Nothing Found', 'twentytwenty' ); 55 } elseif ( ! is_home() ) { 56 $archive_title = get_the_archive_title(); 57 $archive_subtitle = get_the_archive_description(); 58 } 59 60 if ( $archive_title || $archive_subtitle ) { 61 ?> 62 63 <header class="archive-header has-text-align-center header-footer-group"> 64 65 <div class="archive-header-inner section-inner medium"> 66 67 <?php if ( $archive_title ) { ?> 68 <h1 class="archive-title"><?php echo wp_kses_post( $archive_title ); ?></h1> 69 <?php } ?> 70 71 <?php if ( $archive_subtitle ) { ?> 72 <div class="archive-subtitle section-inner thin max-percentage intro-text"><?php echo wp_kses_post( wpautop( $archive_subtitle ) ); ?></div> 73 <?php } ?> 74 75 </div><!-- .archive-header-inner --> 76 77 </header><!-- .archive-header --> 78 79 <?php 80 } 81 82 if ( have_posts() ) { 83 84 $i = 0; 85 86 while ( have_posts() ) { 87 ++$i; 88 if ( $i > 1 ) { 89 echo '<hr class="post-separator styled-separator is-style-wide section-inner" aria-hidden="true" />'; 90 } 91 the_post(); 92 93 get_template_part( 'template-parts/content', get_post_type() ); 94 95 } 96 } elseif ( is_search() ) { 97 ?> 98 99 <div class="no-search-results-form section-inner thin"> 100 101 <?php 102 get_search_form( 103 array( 104 'aria_label' => __( 'search again', 'twentytwenty' ), 105 ) 106 ); 107 ?> 108 109 </div><!-- .no-search-results --> 110 111 <?php 112 } 113 ?> 114 115 <?php get_template_part( 'template-parts/pagination' ); ?> 116 117 </main><!-- #site-content --> 118 119 <?php get_template_part( 'template-parts/footer-menus-widgets' ); ?> 120 121 <?php 122 get_footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sun Dec 22 08:20:01 2024 | Cross-referenced by PHPXref |