Enhance Theme Templates and Editor Layout

This commit is contained in:
2026-07-27 12:34:55 +02:00
parent cbcdbc1bb8
commit 243fb51770
14 changed files with 382 additions and 82 deletions
+11 -3
View File
@@ -1,4 +1,12 @@
<?php // WordPress uses this fallback template when no more-specific request template matches. <?php
get_header(); ?> // WordPress uses this fallback template when no more-specific request template matches.
<main id="main" class="site-main not-found"><p class="hero-eyebrow"><?php esc_html_e( 'Error 404', 'c1024-2026' ); ?></p><h1 class="page-title"><?php esc_html_e( 'Signal lost.', 'c1024-2026' ); ?></h1><p><?php esc_html_e( 'The page you requested could not be found. Search the archive or return to the home page.', 'c1024-2026' ); ?></p><?php get_search_form(); ?><p><a class="button" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php esc_html_e( 'Return home', 'c1024-2026' ); ?></a></p></main> get_header();
?>
<main id="main" class="site-main not-found">
<p class="hero-eyebrow"><?php esc_html_e( 'Error 404', 'c1024-2026' ); ?></p>
<h1 class="page-title"><?php esc_html_e( 'Signal lost.', 'c1024-2026' ); ?></h1>
<p><?php esc_html_e( 'The page you requested could not be found. Search the archive or return to the home page.', 'c1024-2026' ); ?></p>
<?php get_search_form(); ?>
<p><a class="button" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php esc_html_e( 'Return home', 'c1024-2026' ); ?></a></p>
</main>
<?php get_footer(); <?php get_footer();
+17 -3
View File
@@ -1,5 +1,19 @@
<?php get_header(); ?> <?php get_header(); ?>
<header class="page-header"><h1 class="page-title"><?php the_archive_title(); ?></h1><?php the_archive_description( '<div class="archive-description">', '</div>' ); ?></header> <header class="page-header">
<main id="main" class="site-main"><?php // Archive queries use the shared card template and WordPress pagination. <h1 class="page-title"><?php the_archive_title(); ?></h1>
if ( have_posts() ) { while ( have_posts() ) { the_post(); get_template_part( 'template-parts/content' ); } the_posts_pagination( array( 'mid_size' => 1 ) ); } ?></main> <?php the_archive_description( '<div class="archive-description">', '</div>' ); ?>
</header>
<main id="main" class="site-main">
<?php
// Archive queries use the shared card template and WordPress pagination.
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
get_template_part( 'template-parts/content' );
}
the_posts_pagination( array( 'mid_size' => 1 ) );
}
?>
</main>
<?php get_footer(); <?php get_footer();
+15 -5
View File
@@ -1,15 +1,25 @@
<?php <?php
// Protected posts must not expose their discussion until WordPress grants access. // Protected posts must not expose their discussion until WordPress grants access.
if ( post_password_required() ) { return; } if ( post_password_required() ) {
return;
}
?> ?>
<section id="comments" class="comments-area"> <section id="comments" class="comments-area">
<?php if ( have_comments() ) { ?> <?php if ( have_comments() ) { ?>
<h2 class="comments-title"><?php echo esc_html( get_comments_number_text() ); ?></h2> <h2 class="comments-title"><?php echo esc_html( get_comments_number_text() ); ?></h2>
<?php // The custom callback uses an avatar-led, non-numbered discussion layout. ?> <?php // The custom callback uses an avatar-led, non-numbered discussion layout. ?>
<ol class="comment-list"><?php wp_list_comments( array( 'style' => 'ol', 'short_ping' => true, 'avatar_size' => 44, 'callback' => 'c1024_2026_comment' ) ); ?></ol> <ol class="comment-list">
<?php wp_list_comments( array( 'style' => 'ol', 'short_ping' => true, 'avatar_size' => 44, 'callback' => 'c1024_2026_comment' ) ); ?>
</ol>
<?php the_comments_navigation(); ?> <?php the_comments_navigation(); ?>
<?php } ?> <?php } ?>
<?php if ( ! comments_open() && get_comments_number() ) { ?><p><?php esc_html_e( 'Comments are closed.', 'c1024-2026' ); ?></p><?php } ?>
<?php // WordPress provides the form so it respects discussion settings and logged-in state. <?php if ( ! comments_open() && get_comments_number() ) { ?>
comment_form(); ?> <p><?php esc_html_e( 'Comments are closed.', 'c1024-2026' ); ?></p>
<?php } ?>
<?php
// WordPress provides the form so it respects discussion settings and logged-in state.
comment_form();
?>
</section> </section>
+17 -2
View File
@@ -44,7 +44,8 @@
/* Match the frontend's light canvas. The admin chrome is intentionally untouched. */ /* Match the frontend's light canvas. The admin chrome is intentionally untouched. */
body.editor-styles-wrapper { body.editor-styles-wrapper {
max-width: 760px; /* The canvas may be wide; theme.json constrains normal blocks to contentSize. */
max-width: var(--wp--style--global--wide-size, 1180px);
padding: 2rem; padding: 2rem;
margin: 0 auto; margin: 0 auto;
background: #f8f5f0; background: #f8f5f0;
@@ -86,10 +87,24 @@ body.editor-styles-wrapper {
/* /*
* theme.json supplies contentSize and wideSize to Gutenberg's root container. * theme.json supplies contentSize and wideSize to Gutenberg's root container.
* Do not override its alignment geometry here: it also handles full-width blocks * Do not override block alignment geometry here: it also handles full-width blocks
* in the editor sidebar and other constrained editor layouts. * in the editor sidebar and other constrained editor layouts.
*/ */
/* The post-title control sits outside Gutenberg's root block container. */
.editor-post-title,
.editor-post-title__block {
width: 100%;
max-width: var(--wp--style--global--wide-size, 1180px) !important;
margin-right: auto !important;
margin-left: auto !important;
}
.editor-post-title__input {
width: 100%;
max-width: none !important;
}
.editor-styles-wrapper a { .editor-styles-wrapper a {
color: #c3480b; color: #c3480b;
+14 -3
View File
@@ -1,10 +1,21 @@
<footer class="site-footer"> <footer class="site-footer">
<div class="footer-inner"> <div class="footer-inner">
<span>© <?php echo esc_html( wp_date( 'Y' ) ); ?> <?php bloginfo( 'name' ); ?></span> <span>© <?php echo esc_html( wp_date( 'Y' ) ); ?> <?php bloginfo( 'name' ); ?></span>
<?php wp_nav_menu( array( 'theme_location' => 'footer', 'menu_class' => 'footer-menu', 'container' => false, 'fallback_cb' => false ) ); ?> <?php
wp_nav_menu(
array(
'theme_location' => 'footer',
'menu_class' => 'footer-menu',
'container' => false,
'fallback_cb' => false,
)
);
?>
</div> </div>
</footer> </footer>
<?php // Required hook for enqueued footer scripts and plugin output. <?php
wp_footer(); ?> // Required hook for enqueued footer scripts and plugin output.
wp_footer();
?>
</body> </body>
</html> </html>
+50 -8
View File
@@ -1,4 +1,6 @@
<?php get_header(); <?php
get_header();
// The Customizer stores a media attachment ID; resolve it only for the front-page hero. // The Customizer stores a media attachment ID; resolve it only for the front-page hero.
$video_id = absint( get_theme_mod( 'c1024_2026_hero_video' ) ); $video_id = absint( get_theme_mod( 'c1024_2026_hero_video' ) );
$video_url = $video_id ? wp_get_attachment_url( $video_id ) : ''; $video_url = $video_id ? wp_get_attachment_url( $video_id ) : '';
@@ -6,16 +8,56 @@ $hero_title = get_theme_mod( 'c1024_2026_hero_title', get_bloginfo( 'name' ) );
$hero_text = get_theme_mod( 'c1024_2026_hero_text' ); $hero_text = get_theme_mod( 'c1024_2026_hero_text' );
// The site subtitle complements the Customizer-controlled hero headline. // The site subtitle complements the Customizer-controlled hero headline.
$site_description = get_bloginfo( 'description', 'display' ); $site_description = get_bloginfo( 'description', 'display' );
// Keep the hero available for text-only configurations when no video is selected.
if ( $video_url || $hero_title || $hero_text ) {
?> ?>
<?php // Keep the hero available for text-only configurations when no video is selected.
if ( $video_url || $hero_title || $hero_text ) { ?>
<section class="hero" aria-label="<?php esc_attr_e( 'Introduction', 'c1024-2026' ); ?>"> <section class="hero" aria-label="<?php esc_attr_e( 'Introduction', 'c1024-2026' ); ?>">
<?php if ( $video_url ) { ?><video class="hero-video" autoplay muted loop playsinline><source src="<?php echo esc_url( $video_url ); ?>" type="<?php echo esc_attr( get_post_mime_type( $video_id ) ); ?>"></video><?php } ?> <?php if ( $video_url ) { ?>
<div class="hero-content"><?php if ( $site_description ) { ?><div class="hero-eyebrow"><?php echo esc_html( $site_description ); ?></div><?php } ?><?php if ( $hero_title ) { ?><h1 class="hero-title"><?php echo esc_html( $hero_title ); ?></h1><?php } ?><?php if ( $hero_text ) { ?><p class="hero-text"><?php echo esc_html( $hero_text ); ?></p><?php } ?></div> <video class="hero-video" autoplay muted loop playsinline>
</section> <source src="<?php echo esc_url( $video_url ); ?>" type="<?php echo esc_attr( get_post_mime_type( $video_id ) ); ?>">
</video>
<?php } ?> <?php } ?>
<div class="hero-content">
<?php if ( $site_description ) { ?>
<div class="hero-eyebrow"><?php echo esc_html( $site_description ); ?></div>
<?php } ?>
<?php if ( $hero_title ) { ?>
<h1 class="hero-title"><?php echo esc_html( $hero_title ); ?></h1>
<?php } ?>
<?php if ( $hero_text ) { ?>
<p class="hero-text"><?php echo esc_html( $hero_text ); ?></p>
<?php } ?>
</div>
</section>
<?php
}
?>
<main id="main" class="site-main"> <main id="main" class="site-main">
<?php // On a static front page, is_home() identifies the separate posts index; it uses archive cards. <?php
if ( is_home() ) { if ( have_posts() ) { while ( have_posts() ) { the_post(); get_template_part( 'template-parts/content' ); } the_posts_pagination( array( 'mid_size' => 1 ) ); } } else { while ( have_posts() ) { the_post(); ?><article id="post-<?php the_ID(); ?>" <?php post_class(); ?>><div class="entry-content"><?php the_content(); ?></div></article><?php if ( comments_open() || get_comments_number() ) { comments_template(); } } } ?> // On a static front page, is_home() identifies the separate posts index; it uses archive cards.
if ( is_home() ) {
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
get_template_part( 'template-parts/content' );
}
the_posts_pagination( array( 'mid_size' => 1 ) );
}
} else {
while ( have_posts() ) {
the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content"><?php the_content(); ?></div>
</article>
<?php
if ( comments_open() || get_comments_number() ) {
comments_template();
}
}
}
?>
</main> </main>
<?php get_footer(); <?php get_footer();
+55 -12
View File
@@ -7,16 +7,28 @@ function c1024_2026_setup() {
add_theme_support( 'title-tag' ); add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' ); add_theme_support( 'post-thumbnails' );
add_theme_support( 'responsive-embeds' ); add_theme_support( 'responsive-embeds' );
add_theme_support( 'custom-logo', array( 'flex-width' => true, 'flex-height' => true ) ); add_theme_support(
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script' ) ); 'custom-logo',
array(
'flex-width' => true,
'flex-height' => true,
)
);
add_theme_support(
'html5',
array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script' )
);
add_theme_support( 'align-wide' ); add_theme_support( 'align-wide' );
add_theme_support( 'editor-styles' ); add_theme_support( 'editor-styles' );
// Classic-editor stylesheet; the same file is explicitly enqueued for the block editor below. // Classic-editor stylesheet; the same file is explicitly enqueued for the block editor below.
add_editor_style( 'editor-style.css' ); add_editor_style( 'editor-style.css' );
register_nav_menus( array( register_nav_menus(
array(
'primary' => __( 'Primary menu', 'c1024-2026' ), 'primary' => __( 'Primary menu', 'c1024-2026' ),
'footer' => __( 'Footer menu', 'c1024-2026' ), 'footer' => __( 'Footer menu', 'c1024-2026' ),
) ); )
);
} }
// Register theme capabilities before WordPress initializes theme-dependent features. // Register theme capabilities before WordPress initializes theme-dependent features.
add_action( 'after_setup_theme', 'c1024_2026_setup' ); add_action( 'after_setup_theme', 'c1024_2026_setup' );
@@ -36,19 +48,50 @@ add_action( 'enqueue_block_editor_assets', 'c1024_2026_block_editor_assets' );
// These settings drive the optional front-page hero without hard-coding media or copy. // These settings drive the optional front-page hero without hard-coding media or copy.
function c1024_2026_customize_register( $wp_customize ) { function c1024_2026_customize_register( $wp_customize ) {
$wp_customize->add_section( 'c1024_2026_home_hero', array( $wp_customize->add_section(
'c1024_2026_home_hero',
array(
'title' => __( 'Home page video hero', 'c1024-2026' ), 'title' => __( 'Home page video hero', 'c1024-2026' ),
'description' => __( 'Displayed on the site front page.', 'c1024-2026' ), 'description' => __( 'Displayed on the site front page.', 'c1024-2026' ),
'priority' => 30, 'priority' => 30,
) ); )
);
$wp_customize->add_setting( 'c1024_2026_hero_video', array( 'sanitize_callback' => 'absint' ) ); $wp_customize->add_setting( 'c1024_2026_hero_video', array( 'sanitize_callback' => 'absint' ) );
$wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'c1024_2026_hero_video', array( $wp_customize->add_control(
'label' => __( 'Hero video', 'c1024-2026' ), 'section' => 'c1024_2026_home_hero', 'mime_type' => 'video', new WP_Customize_Media_Control(
) ) ); $wp_customize,
$wp_customize->add_setting( 'c1024_2026_hero_title', array( 'default' => get_bloginfo( 'name' ), 'sanitize_callback' => 'sanitize_text_field' ) ); 'c1024_2026_hero_video',
$wp_customize->add_control( 'c1024_2026_hero_title', array( 'label' => __( 'Overlay heading', 'c1024-2026' ), 'section' => 'c1024_2026_home_hero', 'type' => 'text' ) ); array(
'label' => __( 'Hero video', 'c1024-2026' ),
'section' => 'c1024_2026_home_hero',
'mime_type' => 'video',
)
)
);
$wp_customize->add_setting(
'c1024_2026_hero_title',
array(
'default' => get_bloginfo( 'name' ),
'sanitize_callback' => 'sanitize_text_field',
)
);
$wp_customize->add_control(
'c1024_2026_hero_title',
array(
'label' => __( 'Overlay heading', 'c1024-2026' ),
'section' => 'c1024_2026_home_hero',
'type' => 'text',
)
);
$wp_customize->add_setting( 'c1024_2026_hero_text', array( 'sanitize_callback' => 'sanitize_textarea_field' ) ); $wp_customize->add_setting( 'c1024_2026_hero_text', array( 'sanitize_callback' => 'sanitize_textarea_field' ) );
$wp_customize->add_control( 'c1024_2026_hero_text', array( 'label' => __( 'Overlay text', 'c1024-2026' ), 'section' => 'c1024_2026_home_hero', 'type' => 'textarea' ) ); $wp_customize->add_control(
'c1024_2026_hero_text',
array(
'label' => __( 'Overlay text', 'c1024-2026' ),
'section' => 'c1024_2026_home_hero',
'type' => 'textarea',
)
);
} }
// Customize controls are registered only while the Customizer API is available. // Customize controls are registered only while the Customizer API is available.
add_action( 'customize_register', 'c1024_2026_customize_register' ); add_action( 'customize_register', 'c1024_2026_customize_register' );
+46 -6
View File
@@ -22,15 +22,55 @@ wp_body_open(); ?>
<a class="site-title" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a> <a class="site-title" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a>
<?php } ?> <?php } ?>
</div> </div>
<button class="icon-button menu-toggle" type="button" data-menu-toggle aria-expanded="false" aria-controls="primary-menu"><span class="screen-reader-text"><?php esc_html_e( 'Toggle menu', 'c1024-2026' ); ?></span><svg class="icon" aria-hidden="true"><use href="#icon-menu"></use></svg></button> <button class="icon-button menu-toggle" type="button" data-menu-toggle aria-expanded="false" aria-controls="primary-menu">
<span class="screen-reader-text"><?php esc_html_e( 'Toggle menu', 'c1024-2026' ); ?></span>
<svg class="icon" aria-hidden="true"><use href="#icon-menu"></use></svg>
</button>
<nav class="primary-navigation" aria-label="<?php esc_attr_e( 'Primary menu', 'c1024-2026' ); ?>"> <nav class="primary-navigation" aria-label="<?php esc_attr_e( 'Primary menu', 'c1024-2026' ); ?>">
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_id' => 'primary-menu', 'menu_class' => 'primary-menu', 'container' => false, 'fallback_cb' => false ) ); ?> <?php
wp_nav_menu(
array(
'theme_location' => 'primary',
'menu_id' => 'primary-menu',
'menu_class' => 'primary-menu',
'container' => false,
'fallback_cb' => false,
)
);
?>
</nav> </nav>
<div class="header-actions"> <div class="header-actions">
<button class="icon-button" type="button" data-search-toggle aria-expanded="false" aria-controls="site-search"><span class="screen-reader-text"><?php esc_html_e( 'Open search', 'c1024-2026' ); ?></span><svg class="icon" aria-hidden="true"><use href="#icon-search"></use></svg></button> <button class="icon-button" type="button" data-search-toggle aria-expanded="false" aria-controls="site-search">
<button class="icon-button" type="button" data-theme-toggle><span class="screen-reader-text"><?php esc_html_e( 'Change color mode', 'c1024-2026' ); ?></span><svg class="icon" aria-hidden="true"><use data-theme-icon href="#icon-auto"></use></svg></button> <span class="screen-reader-text"><?php esc_html_e( 'Open search', 'c1024-2026' ); ?></span>
<svg class="icon" aria-hidden="true"><use href="#icon-search"></use></svg>
</button>
<button class="icon-button" type="button" data-theme-toggle>
<span class="screen-reader-text"><?php esc_html_e( 'Change color mode', 'c1024-2026' ); ?></span>
<svg class="icon" aria-hidden="true"><use data-theme-icon href="#icon-auto"></use></svg>
</button>
</div> </div>
</div> </div>
<div class="search-panel" id="site-search" data-search-panel><?php get_search_form(); ?></div> <div class="search-panel" id="site-search" data-search-panel>
<?php get_search_form(); ?>
</div>
</header> </header>
<svg width="0" height="0" class="screen-reader-text" aria-hidden="true"><symbol id="icon-search" viewBox="0 0 24 24"><circle cx="10.8" cy="10.8" r="6.5"></circle><path d="m16 16 5 5"></path></symbol><symbol id="icon-light" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4"></circle><path d="M12 2v2m0 16v2M2 12h2m16 0h2M4.9 4.9l1.4 1.4m11.4 11.4 1.4 1.4m0-14.2-1.4 1.4M6.3 17.7l-1.4 1.4"></path></symbol><symbol id="icon-dark" viewBox="0 0 24 24"><path d="M20 15.2A8.5 8.5 0 0 1 8.8 4 8.5 8.5 0 1 0 20 15.2Z"></path></symbol><symbol id="icon-auto" viewBox="0 0 24 24"><circle cx="12" cy="12" r="7"></circle><path d="M12 2v2m0 16v2M2 12h2m16 0h2M5 5l1.4 1.4m11.2 11.2L19 19m0-14-1.4 1.4M6.4 17.6 5 19M9.5 15l2.5-6 2.5 6m-4-2h3"></path></symbol><symbol id="icon-menu" viewBox="0 0 24 24"><path d="M3 6h18M3 12h18M3 18h18"></path></symbol></svg> <svg width="0" height="0" class="screen-reader-text" aria-hidden="true">
<symbol id="icon-search" viewBox="0 0 24 24">
<circle cx="10.8" cy="10.8" r="6.5"></circle>
<path d="m16 16 5 5"></path>
</symbol>
<symbol id="icon-light" viewBox="0 0 24 24">
<circle cx="12" cy="12" r="4"></circle>
<path d="M12 2v2m0 16v2M2 12h2m16 0h2M4.9 4.9l1.4 1.4m11.4 11.4 1.4 1.4m0-14.2-1.4 1.4M6.3 17.7l-1.4 1.4"></path>
</symbol>
<symbol id="icon-dark" viewBox="0 0 24 24">
<path d="M20 15.2A8.5 8.5 0 0 1 8.8 4 8.5 8.5 0 1 0 20 15.2Z"></path>
</symbol>
<symbol id="icon-auto" viewBox="0 0 24 24">
<circle cx="12" cy="12" r="7"></circle>
<path d="M12 2v2m0 16v2M2 12h2m16 0h2M5 5l1.4 1.4m11.2 11.2L19 19m0-14-1.4 1.4M6.4 17.6 5 19M9.5 15l2.5-6 2.5 6m-4-2h3"></path>
</symbol>
<symbol id="icon-menu" viewBox="0 0 24 24">
<path d="M3 6h18M3 12h18M3 18h18"></path>
</symbol>
</svg>
+23 -3
View File
@@ -1,7 +1,27 @@
<?php get_header(); ?> <?php get_header(); ?>
<main id="main" class="site-main"> <main id="main" class="site-main">
<?php // Show the assigned posts-page title, but not when it is also the front page. <?php
if ( is_home() && ! is_front_page() ) { ?><header class="page-header"><h1 class="page-title"><?php single_post_title(); ?></h1></header><?php } ?> // Show the assigned posts-page title, but not when it is also the front page.
<?php if ( have_posts() ) { while ( have_posts() ) { the_post(); get_template_part( 'template-parts/content' ); } the_posts_pagination( array( 'mid_size' => 1 ) ); } else { ?><p><?php esc_html_e( 'No posts found.', 'c1024-2026' ); ?></p><?php } ?> if ( is_home() && ! is_front_page() ) {
?>
<header class="page-header">
<h1 class="page-title"><?php single_post_title(); ?></h1>
</header>
<?php
}
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
get_template_part( 'template-parts/content' );
}
the_posts_pagination( array( 'mid_size' => 1 ) );
} else {
?>
<p><?php esc_html_e( 'No posts found.', 'c1024-2026' ); ?></p>
<?php
}
?>
</main> </main>
<?php get_footer(); <?php get_footer();
+22 -2
View File
@@ -1,6 +1,26 @@
<?php get_header(); ?> <?php get_header(); ?>
<main id="main" class="site-main"> <main id="main" class="site-main">
<?php // Preserve existing discussions even after new comments have been closed. <?php
while ( have_posts() ) { the_post(); ?><article id="post-<?php the_ID(); ?>" <?php post_class(); ?>><header class="entry-header"><?php the_title( '<h1 class="entry-title">', '</h1>' ); ?></header><div class="entry-content"><?php the_content(); wp_link_pages(); ?></div></article><?php if ( comments_open() || get_comments_number() ) { comments_template(); } } ?> // Preserve existing discussions even after new comments have been closed.
while ( have_posts() ) {
the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header>
<div class="entry-content">
<?php
the_content();
wp_link_pages();
?>
</div>
</article>
<?php
if ( comments_open() || get_comments_number() ) {
comments_template();
}
}
?>
</main> </main>
<?php get_footer(); <?php get_footer();
+25 -5
View File
@@ -1,7 +1,27 @@
<?php // This search template is selected by the WordPress template hierarchy. <?php
get_header(); ?> // This search template is selected by the WordPress template hierarchy.
get_header();
?>
<?php // The user-supplied search term is escaped before it enters the translated heading. ?> <?php // The user-supplied search term is escaped before it enters the translated heading. ?>
<header class="page-header"><h1 class="page-title"><?php printf( esc_html__( 'Results for “%s”', 'c1024-2026' ), esc_html( get_search_query() ) ); ?></h1></header> <header class="page-header">
<main id="main" class="site-main"><?php // Empty result sets offer another search form instead of an empty archive. <h1 class="page-title"><?php printf( esc_html__( 'Results for “%s”', 'c1024-2026' ), esc_html( get_search_query() ) ); ?></h1>
if ( have_posts() ) { while ( have_posts() ) { the_post(); get_template_part( 'template-parts/content' ); } the_posts_pagination( array( 'mid_size' => 1 ) ); } else { ?><p><?php esc_html_e( 'Nothing matched your search. Try another term.', 'c1024-2026' ); ?></p><?php get_search_form(); } ?></main> </header>
<main id="main" class="site-main">
<?php
// Empty result sets offer another search form instead of an empty archive.
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
get_template_part( 'template-parts/content' );
}
the_posts_pagination( array( 'mid_size' => 1 ) );
} else {
?>
<p><?php esc_html_e( 'Nothing matched your search. Try another term.', 'c1024-2026' ); ?></p>
<?php get_search_form(); ?>
<?php
}
?>
</main>
<?php get_footer(); <?php get_footer();
+8 -1
View File
@@ -1,6 +1,13 @@
<form role="search" method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>"> <form role="search" method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php // A visually hidden label supplies the search input accessible name. ?> <?php // A visually hidden label supplies the search input accessible name. ?>
<label class="screen-reader-text" for="site-search-field"><?php esc_html_e( 'Search for:', 'c1024-2026' ); ?></label> <label class="screen-reader-text" for="site-search-field"><?php esc_html_e( 'Search for:', 'c1024-2026' ); ?></label>
<input id="site-search-field" class="search-field" type="search" value="<?php echo esc_attr( get_search_query() ); ?>" name="s" placeholder="<?php esc_attr_e( 'Search …', 'c1024-2026' ); ?>"> <input
id="site-search-field"
class="search-field"
type="search"
value="<?php echo esc_attr( get_search_query() ); ?>"
name="s"
placeholder="<?php esc_attr_e( 'Search …', 'c1024-2026' ); ?>"
>
<button class="search-submit" type="submit"><?php esc_html_e( 'Search', 'c1024-2026' ); ?></button> <button class="search-submit" type="submit"><?php esc_html_e( 'Search', 'c1024-2026' ); ?></button>
</form> </form>
+47 -11
View File
@@ -1,17 +1,53 @@
<?php get_header(); ?> <?php get_header(); ?>
<main id="main" class="site-main"> <main id="main" class="site-main">
<?php // The singular main query normally has one post, but retain the standard loop contract. <?php
while ( have_posts() ) { the_post(); ?> // The singular main query normally has one post, but retain the standard loop contract.
while ( have_posts() ) {
the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header"><div class="entry-meta"><time datetime="<?php echo esc_attr( get_the_date( DATE_W3C ) ); ?>"><?php echo esc_html( get_the_date() ); ?></time> · <?php the_author_posts_link(); ?></div><?php the_title( '<h1 class="entry-title">', '</h1>' ); ?><?php // Omit category markup entirely when the post has no assigned categories. <header class="entry-header">
if ( has_category() ) { ?><div class="taxonomy post-categories"><?php the_category( ' ' ); ?></div><?php } ?></header> <div class="entry-meta">
<?php if ( has_post_thumbnail() ) { ?><div class="entry-thumbnail"><?php the_post_thumbnail( 'large' ); ?></div><?php } ?> <time datetime="<?php echo esc_attr( get_the_date( DATE_W3C ) ); ?>"><?php echo esc_html( get_the_date() ); ?></time> · <?php the_author_posts_link(); ?>
<div class="entry-content"><?php the_content(); wp_link_pages(); ?></div> </div>
<footer class="entry-footer"><?php // Tags render separately so untagged posts avoid empty taxonomy output. <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
if ( has_tag() ) { ?><div class="tags-links"><?php the_tags( '', ' ', '' ); ?></div><?php } ?></footer> <?php
</article> // Omit category markup entirely when the post has no assigned categories.
<?php // Retain existing discussions even after comments are closed. if ( has_category() ) {
if ( comments_open() || get_comments_number() ) { comments_template(); } the_post_navigation(); ?> ?>
<div class="taxonomy post-categories"><?php the_category( ' ' ); ?></div>
<?php
}
?>
</header>
<?php if ( has_post_thumbnail() ) { ?>
<div class="entry-thumbnail"><?php the_post_thumbnail( 'large' ); ?></div>
<?php } ?> <?php } ?>
<div class="entry-content">
<?php
the_content();
wp_link_pages();
?>
</div>
<footer class="entry-footer">
<?php
// Tags render separately so untagged posts avoid empty taxonomy output.
if ( has_tag() ) {
?>
<div class="tags-links"><?php the_tags( '', ' ', '' ); ?></div>
<?php
}
?>
</footer>
</article>
<?php
// Retain existing discussions even after comments are closed.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
the_post_navigation();
}
?>
</main> </main>
<?php get_footer(); <?php get_footer();
+19 -5
View File
@@ -1,11 +1,25 @@
<article id="post-<?php the_ID(); ?>" <?php post_class( 'post-card' ); ?>> <article id="post-<?php the_ID(); ?>" <?php post_class( 'post-card' ); ?>>
<header class="entry-header"> <header class="entry-header">
<div class="entry-meta"><time datetime="<?php echo esc_attr( get_the_date( DATE_W3C ) ); ?>"><?php echo esc_html( get_the_date() ); ?></time><?php if ( get_the_author() ) { ?> · <?php the_author_posts_link(); ?><?php } ?></div> <div class="entry-meta">
<time datetime="<?php echo esc_attr( get_the_date( DATE_W3C ) ); ?>"><?php echo esc_html( get_the_date() ); ?></time><?php if ( get_the_author() ) { ?> · <?php the_author_posts_link(); ?><?php } ?>
</div>
<?php the_title( sprintf( '<h2 class="entry-title"><a href="%s">', esc_url( get_permalink() ) ), '</a></h2>' ); ?> <?php the_title( sprintf( '<h2 class="entry-title"><a href="%s">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>
<?php // Avoid an empty category container when no categories are assigned. <?php
if ( has_category() ) { ?><div class="taxonomy post-categories"><?php the_category( ' ' ); ?></div><?php } ?> // Avoid an empty category container when no categories are assigned.
if ( has_category() ) {
?>
<div class="taxonomy post-categories"><?php the_category( ' ' ); ?></div>
<?php
}
?>
</header> </header>
<?php // This repeats the title link, so exclude it from keyboard and assistive-tech navigation. <?php
if ( has_post_thumbnail() ) { ?><a class="entry-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1"><?php the_post_thumbnail( 'large' ); ?></a><?php } ?> // This repeats the title link, so exclude it from keyboard and assistive-tech navigation.
if ( has_post_thumbnail() ) {
?>
<a class="entry-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1"><?php the_post_thumbnail( 'large' ); ?></a>
<?php
}
?>
<div class="entry-summary"><?php the_excerpt(); ?></div> <div class="entry-summary"><?php the_excerpt(); ?></div>
</article> </article>