• Home
  • About

Snippet IT

IT News, Programming, Internet and Blogging

  • Programming and Scripting
  • Tips and Tricks
  • Software and Hardware
  • New and Happening
You are here: Home / Programming and Scripting / Wordpress Theme: How to Enable Gravatar in Wordpress Theme

WordPress Theme: How to Enable Gravatar in WordPress Theme

May 8, 2009 by Sze Hau 2 Comments

Gravatars are Globally Recognized Avatars. An avatar or gravatar is an icon, or representation, of a user in a shared virtual reality, such as a forum, chat, website, or any other form of online community in which the user(s) wish to have something to distinguish themselves from other users. 

Gravatar 

To enable Gravatar in your WordPress theme’s comments, you will need to have some knowledge on editing PHP code and a little bit knowledge on WordPress architecture. The minimum requirement to allow Gravatar to work on your theme is to have WordPress running at version at least 2.5.

Open and edit the file that contains the code to generate comments (normally comments.php) in your WordPress theme folder. Find the portion of code where all comments are looped and printed out. For example:

<?php foreach ($comments as $comment) : ?>
  ......
<?php endforeach; /* end for each comment */ ?>

Put the following code in the portion of code above:

<?php echo get_avatar( $comment, $size = '64' );  ?>

Depending on how large is the Gravatar image you want to display on your page, you can adjust the $size = '64' to other value (pixels). The default size if 92 pixels if you don’t specified the size value.

Read WordPress Codex for more on using Gravatar.

More from my site

  • Wordpress: How To Change Admin UsernameWordPress: How To Change Admin Username
  • Linux: How To Compress And Decompress Folders And FilesLinux: How To Compress And Decompress Folders And Files
  • Java: How To Select Top N Objects From A ListJava: How To Select Top N Objects From A List
  • Java: How To Create A Simple Web Server Using HttpServerJava: How To Create A Simple Web Server Using HttpServer
  • Java: Format Integer Into Fixed Width StringJava: Format Integer Into Fixed Width String
  • Wordpress: Version 2.9WordPress: Version 2.9

Filed Under: Programming and Scripting, Tips and Tricks Tagged With: Gravatar, how to, wordpress theme

About Sze Hau

Geek. Love programming. Coffee addicted. Married with two children. Working towards financial freedom.

Comments

  1. Nayland Smith says

    November 30, 2009 at 5:16 am

    Thanks a lot!!!
    I was looking for this.
    I hope you like my gravatar 😛

  2. szehau says

    November 30, 2009 at 10:44 am

    That is a cool one!

Leave a Reply Cancel reply

Advertisement

  • Facebook
  • Google+
  • Instagram
  • Twitter

Email News Letter

Sign up to receive updates daily and to hear what's going on with us

Software and Hardware

MD5 and SHA1 Checksum Using Windows

July 5, 2017 By Sze Hau Leave a Comment

Blog Network

  • Personal Fincance Personal Finance – Personal Money Tips, Stock Investment, Small Business and Make Money Online
  • szehau's weblog Life, Internet, Software, Gadgets, Programming and Investments

Snippet IT

This is the place where I want to share anything about information technology.

Search

Recent

  • MD5 and SHA1 Checksum Using Windows
  • MD5 and SHA1 Checksum Using Linux
  • Java: Unlimited Strength Jurisdiction Policy
  • WordPress: How To Change Admin Username
  • Linux: How To Compress And Decompress Folders And Files

Tags

Adsense advertisement advertising apache blog blogging tips C# EGPC error estimation format format Integer Gmail Google Google Adsense Google Chrome Google Search Engine Google search result how to HTTP internet marketing Java JavaScript Linux money password performance PHP programming search engine optimization secure security short URL SQL static constructor String tiny URL Tips and Tricks twitter video Windows Vista Wordpress wordpress plugin wordpress theme Youtube

Copyright © 2025 · Magazine Pro Theme on Genesis Framework · WordPress · Log in