Last active
August 29, 2015 14:01
-
-
Save cdils/4e6a67b268ce6c5e36ff to your computer and use it in GitHub Desktop.
Two methods to add post author avatar to entry header
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 // remove this line | |
/** | |
* Hook author avatar by post title on single post | |
* | |
* @uses get_avatar() <http://codex.wordpress.org/Function_Reference/get_avatar> | |
* @uses get_author_posts_url() <http://codex.wordpress.org/Function_Reference/get_author_posts_url> | |
*/ | |
add_action( 'genesis_entry_header', 'cd_author_gravatar' ); | |
function cd_author_gravatar() { | |
if ( is_singular( 'post' ) ) { | |
$entry_author = get_avatar( get_the_author_meta( 'email' ), 64 ); | |
$author_link = get_author_posts_url( get_the_author_meta( 'ID' ) ); | |
printf( '<div class="author-avatar"><a href="%s">%s</a></div>', $author_link, $entry_author ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment