I would like to add author gravatar to all my posts, but I'm having a hard time finding a way to do this. I assume I need to filter the post meta data, but I'm not sure where to start.
ThemeShaper Forums » Thematic
Adding Gravar to Posts
(6 posts)-
Posted 1 year ago #
-
try reading the primer i just wrote for someone else on how to add things to hooks and how to filter things
Posted 1 year ago # -
Fantastic resouce, Helga. I think I'm on the right track, but I'm missing something. Here's what I've got right now:
// Add Author Gravatar to Posts
function author_gravatar() {
return '$postmeta' . 'echo get_avatar($author_email, '80')';
}
add_filter('thematic_postheader' . 'author_gravatar');Posted 1 year ago # -
Okay, I've got it displaying now. I still need to fiddle with styling, and figure out how to keep it from displaying on pages, but if anyone's interested here's what I did:
// Add Author Gravatar
function author_gravatar($postmeta) {
$author_avatar = get_avatar( get_the_author_email(), '80' );
$postmeta .= $author_avatar;
return $postmeta;
}add_filter('thematic_postheader', 'author_gravatar');
Posted 1 year ago # -
glad that helped.
to not display on pages simply wrap the insides w/ a conditional tag
is_page() test for whether it is a page or not
! makes it negative.... so NOT a page.codex.wordpress.org/Conditional_Tags
function bacon(){ if(!is_page(){ echo "sooo not a page. let's have bacon"; } } add_action('thematic_before','bacon');Posted 1 year ago # -
Very helpful! Now I just need to find the best way to style it. Wrapping the avatar in a div seems to work, but it seems like there's probably a better way of doing it.
Current output:
// Add Author Gravatar to Posts
function author_gravatar($postmeta) {
$author_avatar = '<div class="author-avatar">'; // Trying to format the image by containing it in a div. Not sure if thats the right move.
$author_avatar .= get_avatar( get_the_author_email(), '80' );
$author_avatar .= '</div>';
if(!is_page() ) {
$postmeta .= $author_avatar;
}
return $postmeta;add_filter('thematic_postheader', 'author_gravatar');
}add_filter('thematic_postheader', 'author_gravatar');
Posted 1 year ago #
Topic Closed
This topic has been closed to new replies.