Posts Tagged ‘wordpress tips’

Adding Gravatar on Wordpress 2.5 Theme

Thursday, June 12th, 2008

I encourage everyone to use Gravatar once you upgraded to wordpress 2.5. The latest WordPress 2.5 has built-in Gravatar support so you don't need to install a Gravatar plugins. All you need to do is open your comments.php and look for comments loop where you want the Gravatar to show up.

My comments loop look like this, it may vary on different theme.

 
<?php foreach ($comments as $comment) : ?> /*start of the loop*/
<li class="<?php echo $oddcomment; ?>"
id="comment-<?php comment_ID() ?>">
 

Code for Gravatar

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

Add the Gravatar code to you comments.php like this

 
<?php foreach ($comments as $comment) : ?>
<li class="<?php echo $oddcomment; ?>"
id="comment-<?php comment_ID() ?>">
<div class="gravatarstyle">
<?php if(function_exists('get_avatar')){
echo get_avatar($comment, 50);
} ?>
</div>
 

Add some style to your gravatar, experiment with spacing or add border

 
.gravatarstyle { float:left; padding-right:10px; }
 

Now your done! See sample comment below.

How to highlight author comments in WordPress

Friday, June 6th, 2008

Here's how to make your own comments background color different from the rest of the commenter's without using plugin.

First Step

Open your style.css or whatever the name of your css and add the following code

 
.authcomment
{
/*Use different color to match your theme*/
background-color: #B3FFCC !important;
}
 

Step Two

Open your comments.php and look for the line similar to this code since almost of the theme are derived from "Kubrick theme" which is the default theme of wordpress.

 
<li class="$oddcomment;" id="comment-<?php comment_ID() ?>">
 

And replace it with the following code

 
<li class="<?php
/* Only use the .authcomment  class from style.css +
if the user_id is 1 (admin) */
if (1 == $comment->user_id) $oddcomment = "authcomment";
echo $oddcomment;
?>" id="comment-<?php comment_ID() ?>">
 

You are done! See my sample comment below.