Skip to content

Instantly share code, notes, and snippets.

@hellofromtonya
Created December 15, 2016 18:49
Show Gist options
  • Save hellofromtonya/916d5c234c4b8106c71f273bc707ea5d to your computer and use it in GitHub Desktop.
Save hellofromtonya/916d5c234c4b8106c71f273bc707ea5d to your computer and use it in GitHub Desktop.
Example of registered callback hook - to the "the_title" event
add_action( 'the_title', 'add_markup_to_post_title' );
/**
* Adds the HTML Markup to the Post Title.
*
* @since 1.0.0
*
* @param string $title
*
* @return string
*/
function add_markup_to_post_title( $title ) {
if ( is_singular() ) {
$heading_tag = 'h1';
} else {
$title = sprintf( '<a href="%s" rel="bookmark">%s</a>', get_permalink(), $title );
$heading_tag = 'h2';
}
return sprintf( '<%1$s class="entry-title" itemprop="headline">%2$s</%1$s>', $heading_tag, $title );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment