Many WordPress User need to display Recent Comment on the sidebar or footer with Gravatar, most of them using plugin, right now I will show you how to Get Recent Comment with Gravatar without plugin. All need to do just write little bit of code and modified as many you want and you need.
On our recent article, I was cover tips to display most commented post with gravatar without plugin, and I hope you’ll enjoy this tricks too, because this trick also simple and of course useful.
Let’s get started, open your sidebar.php or footer.php or whatever files you need to display recent comment and add this code
<?php
$query = "SELECT * from $wpdb->comments WHERE comment_approved= '1'
ORDER BY comment_date DESC LIMIT 0 ,5";
$comments = $wpdb->get_results($query);
if ($comments) {
echo '<ul>';
foreach ($comments as $comment) {
$url = '<a href="'. get_permalink($comment->comment_post_ID).'#comment-'.$comment->comment_ID .'" title="'.$comment->comment_author .' | '.get_the_title($comment->comment_post_ID).'">';
echo '<li>';
echo '<div class="img">';
echo $url;
echo get_avatar( $comment->comment_author_email, $img_w);
echo '</a></div>';
echo '<div class="txt">Par: ';
echo $url;
echo $comment->comment_author;
echo '</a></div>';
echo '</li>';
}
echo '</ul>';
}
?>


The Right Way Highlight Author Comments in WordPress
March 27th, 2010 By WP Tricks Posted in TricksThis Tricks original written by AEXT.net and we only share and to make it more clearly, especially for me. How To Highlight Author Comments in WordPress in the right way.
Highlight Author Comments in WordPress
This code is better for the future and better for scalability such as, if you has more than one author in your WordPress site.
Write down Highlight Author Comments Code below
<li class="comment-container <?php $authID=get_the_author_meta('ID'); if($authID == $comment->user_id) $oddcomment = 'authcomment'; echo $oddcomment; ?>" id="comment-<?php comment_ID(); ?>"> ... </li>Read the rest of this entry »
Amazing Touch
Tags: Author, Comment, Highlight
5 Comments