Title: using gravatar code elsewhere
Last modified: August 18, 2016

---

# using gravatar code elsewhere

 *  [lokjah](https://wordpress.org/support/users/lokjah/)
 * (@lokjah)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/using-gravatar-code-elsewhere/)
 * Im trying to incorporate the gravatar code in other areas of my site and seem
   to be havin a bit of trouble getting it to show up…. at the moment i’m trying
   to add it to the get-commenters code by coffee2code and after alot of attempts
   the closest I can come is getting no php errors but its printing out the last
   bits of the img src
    `bruce" alt="" /> (2) `
 * when using the gravatar code as such :
 * `foreach ($commenters as $commenter) {
    echo $before; if (!empty($commenter->
   comment_author_url)) echo '<a title="Visit ' . $commenter->comment_author . ''
   s site" href="' . $commenter->comment_author_url . '"'; if ($open_in_new_window)
   echo ' target="_blank"'; if (!empty($commenter->comment_author_url)) echo '>';
   echo $commenter->comment_author; if (!empty($commenter->comment_author_url)) 
   echo '</a>'; if (!empty($commenter->comment_author_url)) echo '<img src= "<?php
   gravatar("G", 50, "http://mysite.com/graphics/grav.gif"); ?>" alt="" />'; if ('
   top' == $type) echo ' (' . $commenter->total_comments . ')'; if (!$omit_last_after)
   echo $after; echo "n"; }
 * anyone spot what Im doin wrong?

Viewing 8 replies - 16 through 23 (of 23 total)

[←](https://wordpress.org/support/topic/using-gravatar-code-elsewhere/?output_format=md)
[1](https://wordpress.org/support/topic/using-gravatar-code-elsewhere/?output_format=md)
2

 *  Thread Starter [lokjah](https://wordpress.org/support/users/lokjah/)
 * (@lokjah)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/using-gravatar-code-elsewhere/page/2/#post-156679)
 * yeah 🙂 im doin that…. thanks for all the help man let me try what you just suggested….
 * i think ultimately I would like to be able to impliment the gravatar independent
   from this plugin, just be able to show a gravatar where ever commenter info may
   be, eg, in a sidebar etc…
 *  Thread Starter [lokjah](https://wordpress.org/support/users/lokjah/)
 * (@lokjah)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/using-gravatar-code-elsewhere/page/2/#post-156684)
 * ok removed the if block, but still willy nillyâ„¢ on the grav display…
 *  [Nick Momrik](https://wordpress.org/support/users/mtdewvirus/)
 * (@mtdewvirus)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/using-gravatar-code-elsewhere/page/2/#post-156685)
 * Slaps forehead!!
 * I just looked at the plugin and it’s using the global variable $comment. This
   is the reason for your sporadic results. You could rename every occurrence of
   $commenter in your plugin with $comment and that should do the trick.
 * I need to get away from the computer…lines are starting to blur. 😉
 *  [Nick Momrik](https://wordpress.org/support/users/mtdewvirus/)
 * (@mtdewvirus)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/using-gravatar-code-elsewhere/page/2/#post-156692)
 * lokjah,
    I emailed you custom version of the plugin that you can use anywhere,
   by passing the function an email address.
 *  Thread Starter [lokjah](https://wordpress.org/support/users/lokjah/)
 * (@lokjah)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/using-gravatar-code-elsewhere/page/2/#post-156696)
 * u rock… do the dew!
 * well we are getting somewhere now…. the other commenters gravs are showing correctly
   in addition to mine, however now we arent getting the default to show up…
 *  Thread Starter [lokjah](https://wordpress.org/support/users/lokjah/)
 * (@lokjah)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/using-gravatar-code-elsewhere/page/2/#post-156698)
 * woot.. fixed that….just had the wrong file path this time….
 * thanks again dew!
 *  [Nick Momrik](https://wordpress.org/support/users/mtdewvirus/)
 * (@mtdewvirus)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/using-gravatar-code-elsewhere/page/2/#post-156717)
 * 🙂
 *  [7milesdown](https://wordpress.org/support/users/7milesdown/)
 * (@7milesdown)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/using-gravatar-code-elsewhere/page/2/#post-156730)
 * MtDewVirus. Can you post the cleaned up coding here? This goes in the usercomments
   php right?

Viewing 8 replies - 16 through 23 (of 23 total)

[←](https://wordpress.org/support/topic/using-gravatar-code-elsewhere/?output_format=md)
[1](https://wordpress.org/support/topic/using-gravatar-code-elsewhere/?output_format=md)
2

The topic ‘using gravatar code elsewhere’ is closed to new replies.

 * 23 replies
 * 3 participants
 * Last reply from: [7milesdown](https://wordpress.org/support/users/7milesdown/)
 * Last activity: [21 years, 2 months ago](https://wordpress.org/support/topic/using-gravatar-code-elsewhere/page/2/#post-156730)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
