WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to add avatars to comments with a a theme that doesn't support them. (4 posts)

  1. Voho
    Member
    Posted 2 years ago #

    This is my website.

    The theme I'm using, called "blogum" (which can be downloaded here) does not, by default, support avatars (I'll be using Gravatars) in the theme itself. Before anyone asks, I do have avatars enabled etc. etc. in the WordPress settings. I know I need to add something like...

    <?php if(function_exists('get_avatar')) { echo get_avatar($comment, '40'); } ?>

    in comments.php, and align it to the left with CSS (I want the image to be to the left of the comment itself). That I can do. But I have no idea where to put it in said comments.php. After I searched for a location to put said code, I discovered I'm supposed to put it at the beggining of the "comment loop" in comments.php, usually defined by this code?

    <?php foreach ($comments as $comment) : ?>
      <li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>">
        <cite><?php comment_author_link() ?></cite> Says:

    But I don't see that in my comments.php file at all.

    Here is my comments.php file in it's entirety:

    [ 86 lines of code moderated. For more than 10 lines of code please use pastebin.com instead. ]

    (Apologies for the long code)

    Where should I place this code? Is it different in the latest versions of WordPress, or am I just blind? Any help would be greatly appreciated!

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    in functions.php, you'll probably find a function named commentlist which is called here in your comments.php

    wp_list_comments(array('callback' => 'commentlist'));

    You would add your avatar there... you could probably look at another theme (2011 for instance uses a callback like your theme soes) for help

  3. Voho
    Member
    Posted 2 years ago #

    Thank you very much Rev, that did the trick! This had been bugging me all day, your help is much appreciated =)

  4. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    No problem, glad that worked for you!

Topic Closed

This topic has been closed to new replies.

About this Topic