Created
December 15, 2016 18:49
-
-
Save hellofromtonya/916d5c234c4b8106c71f273bc707ea5d to your computer and use it in GitHub Desktop.
Example of registered callback hook - to the "the_title" event
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
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