Wordpress Comment Section Avatar (Error)

Posted on 2011-10-15
Last Modified: 2012-05-12
Hello, my website: is having some issues with the comment avatars not showing up. I am new to wordpress and everything was custom made so I am not sure where to fix this or how to fix it....

Question by:VenusBreeze
    LVL 70

    Expert Comment

    by:Jason C. Levine
    Assuming your theme has gravatar support in it, the setting is found at: Dashboard | Settings | Discussion | Avatar Display


    Author Comment


    All the settings here are correct, listed as "show avatar" and an image is selceted. I also had some custom work done to the comment section so I think the problem lies here...
    /*     This is comment.phps by Christian Montoya,
        Available to you under the do-whatever-you-want license. If you like it, 
        you are totally welcome to link back to me. 
        Use of this code does not grant you the right to use the design or any of the 
        other files on my site. Beyond this file, all rights are reserved, unless otherwise noted. 
    <!-- Comments code provided by -->
    <?php if (!empty($post->post_password) && $_COOKIE['wp-postpass_'.COOKIEHASH]!=$post->post_password) : ?>
        <p id="comments-locked">Enter your password to view comments.</p>
    <?php return; endif; ?>
    <?php if (pings_open()) : ?>
        <p id="respond"><span id="trackback-link">
            <a href="<?php trackback_url() ?>" rel="trackback">Get a Trackback link</a>
    <?php endif; ?>
    <?php if ($comments) : ?>
        /* Author values for author highlighting */
        /* Enter your email and name as they appear in the admin options */
        $author = array(
                "highlight" => "highlight",
                "email" => "",
                "name" => "Admin"
        /* Count the totals */
        $numPingBacks = 0;
        $numComments  = 0;
        /* Loop throught comments to count these totals */
        foreach ($comments as $comment) {
            if (get_comment_type() != "comment") { $numPingBacks++; }
            else { $numComments++; }
        /* Used to stripe comments */
        $thiscomment = 'odd'; 
        /* This is a loop for printing pingbacks/trackbacks if there are any */
        if ($numPingBacks != 0) : ?>
        <h2 class="comments-header"><?php _e($numPingBacks); ?> Trackbacks/Pingbacks</h2>
        <ol id="trackbacks">
    <?php foreach ($comments as $comment) : ?>
    <?php if (get_comment_type()!="comment") : ?>
        <li id="comment-<?php comment_ID() ?>" class="<?php _e($thiscomment); ?>">
        <?php comment_type(__('Comment'), __('Trackback'), __('Pingback')); ?>: 
        <?php comment_author_link(); ?> on <?php comment_date(); ?>
        <?php if('odd'==$thiscomment) { $thiscomment = 'even'; } else { $thiscomment = 'odd'; } ?>
    <?php endif; endforeach; ?>
    <?php endif; ?>
        /* This is a loop for printing comments */
        if ($numComments != 0) : ?>
    <?php /*?><?php twittar('45', 'default.png', '#e9e9e9', 'twitavatars', 1, 'G'); ?><?php */?>
        <h2 class="comments-header"><?php _e($numComments); ?> Comments</h2>
        <ol id="comments">
        <?php foreach ($comments as $comment) : ?>
        <?php if (get_comment_type()=="comment") : ?>
            <li id="comment-<?php comment_ID(); ?>" class="<?php 
            /* Highlighting class for author or regular striping class for others */
            /* Get current author name/e-mail */
            $this_name = $comment->comment_author;
            $this_email = $comment->comment_author_email;
            /* Compare to $author array values */
            if (strcasecmp($this_name, $author["name"])==0 && strcasecmp($this_email, $author["email"])==0)
    		<?php /*?><?php echo get_avatar($comment,$size='80',$default='<path_to_url>' ); ?><?php */?>
            <?php echo get_avatar( $comment, 80,''); ?>
            <?php /*?><?php if(function_exists("get_avatar")) echo get_avatar( $comment,$size='80'); ?><?php */?>
                <div id="guser2"><?php /*?><div class="comment-meta"><?php */?>
    <?php /* If you want to use gravatars, they go somewhere around here */ ?>
    <a id="guseri" href="<?php the_author_meta( 'user_url'); ?>"><?php printf(__('%s'), get_comment_author_link()) ?></a><a id="gdate" href="<?php the_author_meta( 'user_url'); ?>" class="comment-date"><?php comment_date() ?></a></div>
    	<?php /*?><span class="comment-author"><?php comment_author_link() ?></span>, <?php */?>
                <div class="gcomment">
    <?php /* Or maybe put gravatars here. The typical thing is to float them in the CSS */ 
        /* Typical gravatar call: 
            <img src="<?php gravatar("R", 80, "YOUR DEFAULT GRAVATAR URL"); ?>" 
            alt="" class="gravatar" width="80" height="80">
        */ ?>
                    <?php comment_text(); ?>
        <?php if('odd'==$thiscomment) { $thiscomment = 'even'; } else { $thiscomment = 'odd'; } ?>
        <?php endif; endforeach; ?>
        <?php endif; ?>
    <?php else : 
        /* No comments at all means a simple message instead */ 
        <h2 class="comments-header">No Comments Yet</h2>
        <p>You can be the first to comment!</p>
    <?php endif; ?>
    <?php if (comments_open()) : ?>
    <?php /* This would be a good place for live preview... 
        <div id="live-preview">
            <h2 class="comments-header">Live Preview</h2>
            <?php live_preview(); ?>
     */ ?>
        <div id="comments-form">
        <h2 id="comments-header"></h2>
        <?php if (get_option('comment_registration') && !$user_ID ) : ?>
            <p id="comments-blocked">You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=
            <?php the_permalink(); ?>">logged in</a> to post a comment.</p>
        <?php else : ?>
        <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
        <?php if ($user_ID) : ?>
        <p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php">
            <?php echo $user_identity; ?></a>. 
            <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" 
            title="Log out of this account">Logout</a>
        <?php else : ?>
            <p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" />
            <label for="author">Name<?php if ($req) _e(' (required)'); ?></label></p>
            <p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" />
            <label for="email">E-mail (will not be published)<?php if ($req) _e(' (required)'); ?></label></p>
          <input name="gurl" type="text" id="gurl" size="22" />
          <label for="url">Website</label></p>
        <?php endif; ?>
        <?php /* You might want to display this: 
            <p>XHTML: You can use these tags: <?php echo allowed_tags(); ?></p> */ ?>
            <p><textarea name="comment" id="comment" rows="5" cols="30"></textarea></p>
            <?php /* Buttons are easier to style than input[type=submit], 
                    but you can replace: 
                    <button type="submit" name="submit" id="sub">Submit</button>
                    <input type="submit" name="submit" id="sub" value="Submit" />
                    if you like */ 
            <p><button type="submit" name="submit" id="sub">Submit</button>
            <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>"></p>
        <?php do_action('comment_form', $post->ID); ?>
    <?php endif; // If registration required and not logged in ?>
    <?php else : // Comments are closed ?>
        <p id="comments-closed">Sorry, comments for this entry are closed at this time.</p>
    <?php endif; ?>

    Open in new window

    LVL 31

    Accepted Solution

    All you need to show the avatar is

    <?php echo get_avatar( $comment, 80 ); ?>

    The code you are using is

    <?php echo get_avatar( $comment, 80,''); ?>

    The 3rd parameter is overriding the default 'Mystery Man' avatar and trying to grab noavatar.png from that link but it's returning a file not found error.

    See also:
    LVL 70

    Expert Comment

    by:Jason C. Levine
    This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
    When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
    The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
    The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: : Go t…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now