WordPress.org

Make WordPress Core

Ticket #52938: 52938.2.diff

File 52938.2.diff, 1.6 KB (added by sabernhardt, 5 months ago)

adds heading to blog page only if title exists, removes the H1 from posts page site-title

  • src/wp-content/themes/twentytwentyone/index.php

     
    1414 * @since Twenty Twenty-One 1.0
    1515 */
    1616
    17 get_header();
     17get_header(); ?>
    1818
     19<?php if ( is_home() && ! is_front_page() && ! empty( single_post_title( '', false ) ) ) { ?>
     20        <header class="page-header alignwide">
     21                <h1 class="page-title"><?php single_post_title(); ?></h1>
     22        </header><!-- .page-header -->
     23<?php }
     24
    1925if ( have_posts() ) {
    2026
    2127        // Load posts loop.
  • src/wp-content/themes/twentytwentyone/template-parts/header/site-branding.php

     
    2727        <?php if ( $blog_info ) : ?>
    2828                <?php if ( is_front_page() && ! is_paged() ) : ?>
    2929                        <h1 class="<?php echo esc_attr( $header_class ); ?>"><?php echo esc_html( $blog_info ); ?></h1>
    30                 <?php elseif ( is_front_page() || is_home() ) : ?>
     30                <?php elseif ( is_front_page() && ! is_home() ) : ?>
    3131                        <h1 class="<?php echo esc_attr( $header_class ); ?>"><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php echo esc_html( $blog_info ); ?></a></h1>
    3232                <?php else : ?>
    3333                        <p class="<?php echo esc_attr( $header_class ); ?>"><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php echo esc_html( $blog_info ); ?></a></p>