Skip to content

Instantly share code, notes, and snippets.

@hellofromtonya
Last active August 29, 2015 14:03
Show Gist options
  • Save hellofromtonya/e76ef3ce63dc17556dff to your computer and use it in GitHub Desktop.
Save hellofromtonya/e76ef3ce63dc17556dff to your computer and use it in GitHub Desktop.
Add Icon to Post Title for Genesis
add_filter('genesis_post_title_output', 'lunarwp_add_icon_to_post_title', 10, 1);
/**
* Add icon to the Post Title
*
* @since 1.0.0
*
* @param string $title Post Title HTML
* @return string Amended Post Title HTML
*/
function lunarwp_add_icon_to_post_title( $title ) {
$categories = get_the_category();
if ( empty( $categories ) ) return $title;
foreach ( $categories as $category ) {
$icon = sprintf( '<span class="icon-cat-%s"></span>', $category->slug );
break;
}
if ( false === strpos( $title, 'rel="bookmark"' ) ) {
$title = str_replace( 'itemprop="headline">', 'itemprop="headline">' . $icon, $title );
} else {
$title = str_replace( 'rel="bookmark">', 'rel="bookmark">' . $icon, $title );
}
return $title;
}
@hellofromtonya
Copy link
Author

Line 13 - Added the missing closing parenthesis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment