nickcernis
10/14/2014 - 12:10 PM

Change titles from h2 to h1 tags for the blog index in Genesis themes.

Change titles from h2 to h1 tags for the blog index in Genesis themes.

<?php

//* Template Name: Blog


if ( genesis_html5() ) {
	remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
	add_action( 'genesis_entry_header', 'my_h1_blog_title' );
} else {
	remove_action( 'genesis_post_title', 'genesis_do_post_title' );
	add_action( 'genesis_post_title', 'my_h1_blog_title' );
}

function my_h1_blog_title() {
	$title = apply_filters( 'genesis_post_title_text', get_the_title() );

	if ( 0 === mb_strlen( $title ) )
		return;

	//* Link it, if necessary
	if ( !is_singular() && apply_filters( 'genesis_link_post_title', true ) )
		$title = sprintf( '<a href="%s" rel="bookmark">%s</a>', get_permalink(), $title );

	$wrap = 'h1';

	//* Build the output
	$output = genesis_markup( array(
		'html5' => "<{$wrap} %s>",
		'xhtml' => sprintf( '<%s class="entry-title">%s</%s>', $wrap, $title, $wrap ),
		'context' => 'entry-title',
		'echo' => false,
	) );

	$output .= genesis_html5() ? "{$title}</{$wrap}>" : '';

	echo apply_filters( 'genesis_post_title_output', "$output \n" );
}

genesis();