Created
October 14, 2014 12:10
-
-
Save nickcernis/69cf5e47d2bfa2d4adf6 to your computer and use it in GitHub Desktop.
Change titles from h2 to h1 tags for the blog index in Genesis themes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment