'Using WordPress and H1 displayed as blank while post title displayed as H2

I'm using WordPress with Writee theme activated. However, When I checked my H1 its displayed as blank and my post title is classified as H2. I tried checking header.php file and I found this.

    <?php 
/*************************************************************/
## Theme header style . It's header style, part of the theme.
/*************************************************************/

?>
    <header id="site-header" class="site-header">
        <div class="site-header-top">
            <div class="site-container">
                <div class="site-row">
                    
                    <div class="site-header-top-left site-column-9">
                    
                        <?php if ( has_nav_menu( 'primary' ) ) : ?>
                        <nav class="primary-navigation" id="primary-navigation">
                            
                            <?php 
                            $writtyNav = array(
                                'theme_location'  => 'primary',
                                'menu'            => '',
                                'container'       => false,
                                'container_class' => '',
                                'container_id'    => '',
                                'menu_class'      => '',
                                'menu_id'         => '',
                                'echo'            => true,
                                'fallback_cb'     => '',
                                'before'          => '',
                                'after'           => '',
                                'link_before'     => '',
                                'link_after'      => '',
                                'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
                                'depth'           => 0,
                                
                            ); 
                            
                            wp_nav_menu($writtyNav);
                            
                            ?>
                        </nav>
                        <a href="<?php echo esc_url( home_url() ) ; ?>" class="mobile-navigation-toggle"></a>
                        <?php endif ?>
                    </div>
                    
                    <?php writee_get_social(); ?>
                </div>
            </div>
        </div>
        
        <div class="site-header-bottom">
            <div class="site-container">
                <div class="site-row">
                    <div class="site-header-middle-center">
                        <div class="site-brand">
                        <?php
                            $writee_header_text = esc_attr(get_theme_mod('header_text'));
                            if ($writee_header_text): ?>
                            <?php if(!is_single()): 
                            echo '<h1 class="site-heading">'; 
                            else: 
                            echo '<h2 class="site-heading">'; 
                            endif;  ?>
                            <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
                            <?php bloginfo( 'name' ); ?>
                            </a>
                            <?php if(!is_single()): echo '</h1>'; else: echo '</h2>'; endif;  ?>
                            
                        <?php 
                            elseif(has_custom_logo()): 
                        ?>
                        
                            <?php if(!is_single()): echo '<h1 class="site-logo">'; else: echo '<h2 class="site-logo">'; endif;  ?>
                            <?php the_custom_logo(); ?>
                            <?php if(!is_single()): echo '</h1>'; else: echo '</h2>'; endif;  ?>
                            
                        <?php
                            else:
                        ?>
                        
                            <?php if(!is_single()): echo '<h1 class="site-heading">'; else: echo '<h2 class="site-heading">'; endif;  ?>
                            <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
                            <?php if(!is_single()): echo '</h1>'; else: echo '</h2>'; endif;  ?>
                            <?php if(get_bloginfo( 'description' ) != '') : ?>
                            <p class="site-tagline"><?php bloginfo( 'description' ); ?></p>
                            <?php endif; ?>

                        <?php endif;  ?>
                        
                    
                        <?php if($writee_header_text && get_bloginfo( 'description' ) != ''): ?>
                            <p class="site-tagline"><?php bloginfo( 'description' ); ?></p>
                        <?php endif; ?>
                        
                        <a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="mobile-navigation-toggle"></a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </header><!-- / header -->

How can I solve this? I want my H1 be displayed normally as H1.



Solution 1:[1]

You would have to rework the if statements. I removed the h2 tags and kept all the h1 tags.

<header id="site-header" class="site-header">
        <div class="site-header-top">
            <div class="site-container">
                <div class="site-row">
                    
                    <div class="site-header-top-left site-column-9">
                    
                        <?php if ( has_nav_menu( 'primary' ) ) : ?>
                        <nav class="primary-navigation" id="primary-navigation">
                            
                            <?php 
                            $writtyNav = array(
                                'theme_location'  => 'primary',
                                'menu'            => '',
                                'container'       => false,
                                'container_class' => '',
                                'container_id'    => '',
                                'menu_class'      => '',
                                'menu_id'         => '',
                                'echo'            => true,
                                'fallback_cb'     => '',
                                'before'          => '',
                                'after'           => '',
                                'link_before'     => '',
                                'link_after'      => '',
                                'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
                                'depth'           => 0,
                                
                            ); 
                            
                            wp_nav_menu($writtyNav);
                            
                            ?>
                        </nav>
                        <a href="<?php echo esc_url( home_url() ) ; ?>" class="mobile-navigation-toggle"></a>
                        <?php endif ?>
                    </div>
                    
                    <?php writee_get_social(); ?>
                </div>
            </div>
        </div>
        
        <div class="site-header-bottom">
            <div class="site-container">
                <div class="site-row">
                    <div class="site-header-middle-center">
                        <div class="site-brand">
                        <?php
                            $writee_header_text = esc_attr(get_theme_mod('header_text'));
                            if ($writee_header_text): ?>
                            <?php if(!has_custom_logo()): ?>
                            <h1 class="site-heading">
                                <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
                                <?php bloginfo( 'name' ); ?>
                            </a>
                            </h1>
                            
                        <?php 
                            elseif(has_custom_logo()): 
                        ?>
                        
                            <?php if(!is_single()): echo '<h1 class="site-logo">'; else: echo '<h2 class="site-logo">'; endif;  ?>
                            <?php the_custom_logo(); ?>
                            <?php if(!is_single()): echo '</h1>'; else: echo '</h2>'; endif;  ?>
                            
                        <?php
                            else:
                        ?>
                        
                            <h1 class="site-heading">
                                <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
                            </h1>
                            <?php if(get_bloginfo( 'description' ) != '') : ?>
                            <p class="site-tagline"><?php bloginfo( 'description' ); ?></p>
                            <?php endif; ?>

                        <?php endif;  ?>
                        
                    
                        <?php if($writee_header_text && get_bloginfo( 'description' ) != ''): ?>
                            <p class="site-tagline"><?php bloginfo( 'description' ); ?></p>
                        <?php endif; ?>
                        
                        <a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="mobile-navigation-toggle"></a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </header><!-- / header -->

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nimantha