Last active
August 29, 2015 13:58
-
-
Save robneu/9952103 to your computer and use it in GitHub Desktop.
This file contains 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 | |
add_filter( 'genesis_seo_title', 'prefix_seo_title_fix' ); | |
/** | |
* Correct a bug in Genesis that causes the home page title to display with a p | |
* tag instead of a h1 tag when a static front page is in use. | |
* | |
* @copyright Copyright (c) 2014, FAT Media, LLC | |
*/ | |
function prefix_seo_title_fix( $title, $inside, $wrap ) { | |
//* Set what goes inside the wrapping tags | |
$inside = sprintf( '<a href="%s" title="%s">%s</a>', trailingslashit( home_url() ), esc_attr( get_bloginfo( 'name' ) ), get_bloginfo( 'name' ) ); | |
//* Determine which wrapping tags to use | |
$wrap = is_front_page() && 'title' === genesis_get_seo_option( 'home_h1_on' ) ? 'h1' : 'p'; | |
//* A little fallback, in case an SEO plugin is active | |
$wrap = is_front_page() && ! genesis_get_seo_option( 'home_h1_on' ) ? 'h1' : $wrap; | |
//* And finally, $wrap in h1 if HTML5 & semantic headings enabled | |
$wrap = genesis_html5() && genesis_get_seo_option( 'semantic_headings' ) ? 'h1' : $wrap; | |
//* Build the title | |
$title = genesis_html5() ? sprintf( "<{$wrap} %s>", genesis_attr( 'site-title' ) ) : sprintf( '<%s id="title">%s</%s>', $wrap, $inside, $wrap ); | |
$title .= genesis_html5() ? "{$inside}</{$wrap}>" : ''; | |
return $title; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment