I got an interesting request this week to change his Genesis framework child theme’s homepage .site-title
H1
wrap to a p
wrap. I was going to advise against this until the request continued to change one of the widget titles to an H1
and become his new site’s title.
My first thought was that I had to edit the entire header or site title with a filter but it was actually much more simple than that.
Looking at the Genesis core code, it starts off looking like something familiar: adding a filter for genesis_seo_title
. Then I saw something else by jumping around a bit in that area of lib/structure/header.php
:
// And finally, $wrap in h1 if HTML5 & semantic headings enabled. $wrap = genesis_html5() && genesis_get_seo_option( 'semantic_headings' ) ? 'h1' : $wrap; $wrap = apply_filters( 'genesis_site_title_wrap', $wrap );
Aha! Could it really be as simple as changing that heading in the wrap? As we read on in the file, we see more evidence that is how things work:
// Determine which wrapping tags to use. $wrap = genesis_is_root_page() && 'description' === genesis_get_seo_option( 'home_h1_on' ) ? 'h1' : 'p'; // Wrap homepage site description in p tags if static front page. $wrap = is_front_page() && ! is_home() ? 'p' : $wrap; // And finally, $wrap in h2 if HTML5 & semantic headings enabled. $wrap = genesis_html5() && genesis_get_seo_option( 'semantic_headings' ) ? 'h2' : $wrap;
So this is the code to change the site title’s wrap when on the front-page… by placing this in the front-page.php file found in most of the child themes:
//* Change site-title SEO wrap add_filter('genesis_site_title_wrap','seo_wrap_site_title'); function seo_wrap_site_title($wrap) { return 'p'; }
This matches what the title wrap is on inner pages and I won’t dwell on or try to figure out why this child theme’s front-page title wasn’t already how the client wanted, but now you, too, have the code to change the wrap on the site title in Genesis with a very easy filter.