Skip to content

Instantly share code, notes, and snippets.

@SiGaCode
Created February 24, 2018 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiGaCode/835fb90939fce1df99493759b121f3b1 to your computer and use it in GitHub Desktop.
Save SiGaCode/835fb90939fce1df99493759b121f3b1 to your computer and use it in GitHub Desktop.
Filter the Genesis site title to output as h1 on the frontpage and with a custom class. Credits: Carrie Dils, https://gist.github.com/cdils/9002451
// =========== Filter the site title with a custom function ============================
add_filter('genesis_seo_title', 'siga_site_title' );
// Add additional custom style to site header
function siga_site_title( $title ) {
// Change $custom_title text as you wish
$custom_title = 'SG-Layout';
// Don't change the rest of this on down
// If we're on the front page or home page, use `h1` heading, otherwise us a `p` tag
$tag = ( is_home() || is_front_page() ) ? 'h1' : 'p';
// Compose link with title
$inside = sprintf( '<a href="%s" title="%s">%s</a>', trailingslashit( home_url() ), esc_attr( get_bloginfo( 'name' ) ), $custom_title );
// Wrap link and title in semantic markup
$title = sprintf ( '<%s class="site-title" itemprop="headline">%s</%s>', $tag, $inside, $tag );
return $title;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment