Support » Fixing WordPress » Gravatar in Byline

  • Resolved Odjur


    First of all… great theme! Kudos to the developer.

    I have a multi-author blog and I would like to post the author gravatar in the byline. I can add the name by typing %author% in the appropriate section in post/page info items but there is no option for gravatar. I’ve been using this post as a guide but am not having much luck. I keep breaking the code when I try to edit it directly.


Viewing 3 replies - 1 through 3 (of 3 total)
  • At the bottom of postinfo.php, before
    return $postinfo;

    put this

    if (strpos($postinfo_string,'%gravatar%')!==FALSE) {
    $author_email = get_the_author_email();
    $gravatar = get_avatar($author_email, '30');
    $postinfo = str_replace("%gravatar%", $gravatar, $postinfo);

    Then use %gravatar% in the post info items

    I’ll add gravatars to the post info items in a later version but may not be able to include this in v. 3.2.1

    Brilliant! That did it. I wouldn’t have figured that out on my own. Thanks for the quick reply.

    Hi there,

    I have the following code in my single.php

    Its supposed to pull the Gravatar for the relevant author who has written the post and display their name as well within each single post. Similar code is within my comments.php and this works fine.

    I can’t understand what I am missing – I’m no expert!

    Thanks in advance –


    <?php if (get_option(‘woo_author’) != “”) { ?>

    <div class=”author_info”>
    <h3>This post was written by:</h3>

    // Determine which gravatar to use for the user
    $email = get_the_author_email();
    $grav_url = “”.md5($email). “&default=”.urlencode($GLOBALS[‘defaultgravatar’] ).”&size=48″;
    $usegravatar = get_option(‘woo_gravatar’);

    <?php if ( $usegravatar ) { ?><span class=”author_photo”><img src=”<?php echo $grav_url; ?>” width=”48″ height=”48″ alt=”” /></span><?php } ?>
    <p><?php the_author_posts_link(); ?> – who has written <?php the_author_posts(); ?> posts on /”><?php bloginfo(‘name’); ?>.</p>
    <p><?php the_author_description(); ?> <br style=”clear:both;” /></p>
    <p class=”author_email”>”>Contact the author</p>

    <?php } ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Gravatar in Byline’ is closed to new replies.