Code Snippets

Fix H1 Title Markup in Genesis Child Themes

Genesis WordPress Child Themes wrap the site title in an H1 tag. This is an SEO problem because it results in two H1s on every page and post on your site. Here's a WordPress PHP code snippet to fix this issue.

The Site Title should only be wrapped in an H1 tag on the home page. Otherwise you’ll have two H1s on every page and post on your site.

Genesis Framework Version 2.6 (at least) and higher have resolved this.

Modify The Title Markup Site Wide

/* Remove Default Site Title and Description because they have H1 and H2 tags */
/* Add back title and description with other tags to avoid duplicate H1s and H2s.*/
remove_action( 'genesis_site_title', 'genesis_seo_site_title' );
remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
add_action( 'genesis_site_title', 'child_seo_site_title' );
function child_seo_site_title() { 
 	echo '<span><span><a href="/" title="Home">Chris Bryant</a></span><span>/</span>Web Design + Digital Strategy for Business</span>';
}

Change the Homepage to H1 but modify the title everywhere else.


//Dynamic Site Title Class - haven't tested this completely
add_action( 'genesis_site_title', 'em_dynamic_site_title' );
function em_dynamic_site_title() {
	if(is_home() || is_front_page()) { ?> 
		<h1 id="site-title"><a href="/" title="Home"><?php bloginfo('name');?></a></h1>
	<?php } else { ?>
		<span id="site-title"><a href="/" title="Home"><?php bloginfo('name');?></a></span>
	<?php }
}

Hire a WordPress Expert

Get hourly and project based theme customization, theme tweaks, and development help from an experienced Kelowna WordPress developer.  We’ve been building WordPress websites full-time for over a decade. We can help you.