• Skip to main content
  • Skip to primary sidebar
Martin Taylor

Martin Taylor

PHP, CSS, MySQL and WordPress tips and techniques

Overriding site title in a Genesis theme

Posted on May 8, 2020

I wanted to make the whole site title and tagline area into a link to the home page, on my Genesis-themed site. By default, only the site title is hyperlinked by Genesis. To make matters a tad more complicated, the area containing the two pieces of text has a background image, offset to the left of the text.

The HTML for the area in question, as output by Genesis, goes like this:

<div class="title-area">
<h1 class="site-title" itemprop="headline">
<a href="http://mysite.com/">Site name</a>
</h1>
<p class="site-description" itemprop="description">Site tagline</p>
</div>

Essentially, then, I wanted to add a hyperlink around the whole of this block, and to remove the link you can see on the site name.

Reading up about Genesis filters, I found that there are a number of likely candidates. They all belong to the genesis_markup family, and you can be quite specific in targeting a particular context.

For example, Genesis precedes the title area with this code:

genesis_markup(
	[
		'open'    => '<div %s>',
		'context' => 'title-area',
	]
);

It looked like it should be possible to apply a filter to this at the hook named genesis_markup_title-area, or even genesis_markup_title-area_open.

Suffice to say that I tried for some time to use one or other of these filters but was unsuccessful. Maybe one day I’ll work it out.

In the end I took a more radical approach, and completely over-rode the function that creates this area of the page. I added this code to the functions.php file in my child theme.

remove_action ('genesis_header', 'genesis_do_header');
add_action ('genesis_header', 'custom_do_header');

function custom_do_header() {
	echo '<a class="title-link" href="',get_home_url(),'">';
	echo '<div class="title-area">';	
	echo '<h1 class="site-title" itemprop="headline">',get_bloginfo( 'name' ),'</h1>';
	do_action( 'genesis_site_description' );
	echo '</div>';
	echo '</a>';
}

This works, of course, and i suppose it has the advantage of being simple. It always concerns me, though, that by overriding a parent theme function, I run the risk of missing out on a theme update / improvement. Using hooks and filters should ideally be the way to customise a parent theme.

Filed under: Genesis, WordPress

Primary Sidebar

Recent Posts

  • Populating Alpine data in a PHP page (part 2)
  • Thoughts on Tailwind CSS
  • Understanding JavaScript assignments
  • Populating Alpine data in a PHP page (part 1)
  • Alpine JS

Copyright Martin Taylor © 2025