• Resolved edouardcoleman

    (@edouardcoleman)


    Hello,

    How to remove the h1 tags of the site name (under the logo / “site-title”) ?

    Because the page title has already h1s, and I think that’s not good for the SEO to have two h1s in the same page. Also h1s should only be what the page is about.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Subrata Sarkar

    (@subrataemfluence)

    Hi,
    To achieve what you are looking for you need to do the following:

    1. Open functions.php file (this should be here: wp-content/themes/edge/functions.php)

    2. Navigate to line number 225 of locate this: function edge_header_display ()

    3. At line number 230 you find the following code snippet:

    <?php if(is_home() || is_front_page()){ ?>
    <h1 id="site-title"> <?php }else{?> <h2 id="site-title"> <?php } ?>

    Change <h1> to whatever you want.

    Save the file and refresh your browser to see the change taking effect.

    Remember, the <h1></h1> block is applicable only when you are on the home page of your site.

    Hope this will help.

    Thread Starter edouardcoleman

    (@edouardcoleman)

    Hi,

    Thanks a lot for your answer. I managed it by creating a functions.php in my child theme, because I was thinking the modifications into the parent functions.php file would be deleted through the next update ??

    I don’t know anything about PHP, so I made it only by deduction and lot of attempts. That’s why this code is probably not the best 😉 but it worked:

    <?php
    function child_remove_parent_function() {
        remove_action( 'edge_site_branding', 'edge_header_display' );
    }
    add_action( 'wp_loaded', 'child_remove_parent_function' );
    ?>
    
    <?php
    function my_parent_theme_function() {
    		$edge_settings = edge_get_theme_options();
    		$header_display = $edge_settings['edge_header_display'];
    	if ($header_display == 'header_text') { ?>
    		<div id="site-branding">
    		<?php if(is_home() || is_front_page()){ ?>
    		<div id="site-title"> <?php }else{?> <div id="site-title"> <?php } ?>
    			<a href="<?php echo esc_url(home_url('/'));?>" title="<?php echo esc_attr(get_bloginfo('name', 'display'));?>" rel="home"> <?php bloginfo('name');?> </a>
    		<?php if(is_home() || is_front_page() || is_search()){ ?>
    		</div>  <!-- end .site-title -->
    		<?php } else { ?> </div> <!-- end .site-title --> <?php } 
    		$site_description = get_bloginfo( 'description', 'display' );
    		if($site_description){?>
    		<p id ="site-description"> <?php bloginfo('description');?> </p> <!-- end #site-description -->
    		<?php } ?>
    		</div> <!-- end #site-branding -->
    		<?php
    	} elseif ($header_display == 'header_logo') { ?>
    		<div id="site-branding"> <?php edge_the_custom_logo(); ?></div> <!-- end #site-branding -->
    		<?php } elseif ($header_display == 'show_both'){ ?>
    		<div id="site-branding"> <?php edge_the_custom_logo(); ?></a>
    		<?php if(is_home() || is_front_page()){ ?>
    		<div id="site-title"> <?php }else{?> <div id="site-title"> <?php } ?>
    			<a href="<?php echo esc_url(home_url('/'));?>" title="<?php echo esc_attr(get_bloginfo('name', 'display'));?>" rel="home"> <?php bloginfo('name');?> </a>
    			<?php if(is_home() || is_front_page()){ ?> </div> <!-- end .site-title -->
    		<?php }else{ ?> </div> <!-- end .site-title -->
    		<?php }
    		$site_description = get_bloginfo( 'description', 'display' );
    			if($site_description){?>
    			<p id ="site-description"> <?php bloginfo('description');?> </p><!-- end #site-description -->
    		<?php } ?>
    		</div> <!-- end #site-branding -->
    		<?php }
    }
    add_action( 'wp_head', 'my_parent_theme_function' );
    ?>

    I simply replaced all the h1 with div. Then instead of h1 my site name was inside h2s, so I replaced them too.

    What do you think is the best way to remove it? with parent or child functions.php?

    Subrata Sarkar

    (@subrataemfluence)

    Yes, if you change it in theme’s own file it would get lost when you update. So the right approach is to override inside functions.php of your child theme.

    Thread Starter edouardcoleman

    (@edouardcoleman)

    Ok so do you think my code is right ?

    Subrata Sarkar

    (@subrataemfluence)

    Yes, it looks like it – as long as you removed parent theme function and added one for child it should work fine (and in your case it is as you mentioned). Most importantly all your hard work will remain even you update the base theme.

    Good work!

    Thread Starter edouardcoleman

    (@edouardcoleman)

    Thank you !

    Subrata Sarkar

    (@subrataemfluence)

    You are most welcome!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘h1 as site name’ is closed to new replies.