效果的话就是在侧边栏显示最新留言者的头像~然后当鼠标滑到头像的时候显示出留言~效果蛮好的,但是貌似和我的这个现实链接的框框弄的有时候叠加起来了就难看。。。所以就没用~~

效果可以看这里~虽然作者现在用的不是wp,但就是这个效果了~~

via:http://www.tnnde.com/2010/12/48002.html

在需要显示的地方插入

<ul id="recentcomments">
< ?php
global $wpdb, $comments, $comment;
$comments = $wpdb->get_results("SELECT comment_author, comment_author_email, comment_author_url, comment_ID, comment_post_ID, SUBSTRING(comment_content,1,65) AS comment_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 18");
if ($comments): foreach ($comments as $comment): $comment_author_19 = $comment->comment_author;
if ($comment_author_19 == "") {$comment_author_19 = "Anonymous";}
$order = array ("\r\n","\n","\r");
$order2 = array ("\"","\'");
$replace = '';
$tmpstr = str_replace($order2, "", str_replace($order, $replace, sprintf('%s', strip_tags($comment->comment_excerpt))));
$content = '<span class=\'recentcommentslink_author\'>' . $comment_author_19 . '</span> <span class=\'recentcommentslink_on\'>on</span> <span class=\'recentcommentslink_title\'>' . get_the_title($comment->comment_post_ID) . '</span><div class=\'recentcommentslink_excerpt\'>' . $tmpstr . '</div>';
echo '<li><div id="C_' . $comment->comment_ID . '_d" style="display:none">' . $content . '</div>' . '<a title="' . $comment_author_19 . ' on ' . get_the_title($comment->comment_post_ID) . '" id="C_' . $comment->comment_ID . '" href="' . get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '" >' . get_avatar($comment->comment_author_email, 40) . '</a></li>';
endforeach;
endif;
?>
</ul>
<script type="text/javascript">jQuery(document).ready(function(){new tooltip_19(".recentcommentslink");})</script>

修改DESC LIMIT 18来调整最新评论数量,或者你也可以自己写成函数调用,之后加入下面的JS和CSS就行了:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"  type="text/javascript"></script>

JS:

jQuery.noConflict();
var tooltip_19 = function(tid) {
    var xOffset = 10; var yOffset = 20; var t;
    jQuery("a" + tid).hover(function(e) {
        var aid = jQuery(this).attr("id");
        t = jQuery("#" + aid + "_d").html();
        jQuery("body").append("<div id='tooltip_19'>" + t + "</div>");
        jQuery("#tooltip_19").css("top", (e.pageY + yOffset) + "px").css("right", (jQuery(window).width() - e.pageX + xOffset) + "px").fadeIn("fast").show();
    }, function() {jQuery("#tooltip_19").remove();});
    jQuery("a" + tid).mousemove(function(e) {jQuery("#tooltip_19").css("top", (e.pageY + yOffset) + "px").css("right", (jQuery(window).width() - e.pageX + xOffset) + "px").show();});
};

CSS;

#tooltip_19{position:absolute;border:1px solid #222222;background:#FFFFFF;padding:5px;color:#222222;display:none; z-index:23;}
#recentcomments li{float: left; padding:0px;}
.recentcommentslink_author{ font-weight:bold; font-size:1.2em;}
.recentcommentslink_on { padding: 0px 5px 0px 5px; font-style:italic;}
.recentcommentslink_title { color:#666666; font-size:0.8em;}
.recentcommentslink_excerpt {clear:both; color:#333333; font-size:0.9em; width:200px; padding:10px;}
.avatar {border: 1px solid #d3d3d3; background-color: #fff;padding: 1px; margin-bottom: 2px; margin-right: 10px;}