WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin:add local avatar] Help with get_avatar parameters (2 posts)

  1. cerdo75
    Member
    Posted 5 years ago #

    Hi everyone and thank you in advance for taking the time to read my post.

    I just installed the add local avatar plugin to my site and I'm having trouble implementing it on my theme largely because I am a useless coder.

    The instructions for implementing the plugin into the theme are as follows:

    Put this code in your template files where you want avatars to appear:

    <?php echo get_avatar(); ?>

    The function takes the following parameters:

    1. Identifier; NULL (the currently logged in user), user ID (a blog user), e-mail address, or a comment object from WordPress comment loop (for comments).
    2. Size (pixels); defaulted to value set above.
    3. Default image if no public (global) or private (local) avatar found; defaulted to value set above.

    Apply format to the avatars with something like the following in your style.css theme file:

    * For comment avatars, .avatar { float: left; padding: 2px; margin: 0; border: 1px solid #ddd; background: white; }
    * For avatars in post content, .post_avatar { padding: 2px; margin: 0; border: 1px solid #ddd; background: white; }

    Examples for your theme's template files:

    * In single.php declare <?php global $post; ?> if not already declared and then use <?php get_avatar($post->post_author); ?> to show the post author’s avatar.
    * Inside the comment loop of comments.php use <?php get_avatar($comment); ?> to show the comment author’s avatar.

    This seems pretty simple but I just cannot get it to work on my theme.
    I can only get the default avatar to show up when I add <?php echo get_avatar(''); ?> in the loop. This is driving me craaaazy! How do I use the parameters to specify the users avatar?

    Thanks

  2. cerdo75
    Member
    Posted 5 years ago #

    <?php get_avatar($post->post_author); ?>

    The answer was right in front of me. Now I´m sorry to have used up database space on this server but maybe my post helps another hopeless "coder wannabe" like me in the future.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.