可以直接添加插件:cos_visitor_comment

然后在需要的显示访客留言的地方,插入如下代码

1
< ?php show_visitor_comment(5,50,"我的评论");?>

具体的可以搜索插件去作者那看。

OR:

<?php
if($_COOKIE["comment_author_" . COOKIEHASH]!=""){
global $wpdb;
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_author_email, comment_type, comment_author_url, SUBSTRING(comment_content,1,25) AS com_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 comment_author = '".$_COOKIE["comment_author_" . COOKIEHASH]."' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 10";
$comments = $wpdb->get_results($sql);
foreach ($comments as $comment) {
$output .= "\n<li><a href=\"" .get_permalink($comment->ID)."#comment-".$comment->comment_ID. "\" title=\"" . $comment->post_title . " 上的评论\">".strip_tags($comment->comment_author).": ". strip_tags($comment->com_excerpt) ."</a></li>";
}
$output = '<h3>您的足迹</h3><ul>'.$output.'</ul>';
$output = convert_smilies($output);
echo $output;
}
?>
via:http://wange.im/show-your-recent-comments-in-wordpress.html

<?php
if($_COOKIE["comment_author_" . COOKIEHASH]!=""){
//1.如果COOKIE不为空,则输出您的足迹
global $wpdb;//2.读取数据库相关项
$sql = "SELECT DISTINCT ID, post_title,post_password,
comment_ID, comment_post_ID,comment_author,
comment_count,
comment_date_gmt,comment_approved, comment_author_email,
comment_type,comment_author_url,
SUBSTRING(comment_content,1,25)
AS com_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 comment_author = '".$_COOKIE["comment_author_" . COOKIEHASH]."'
AND post_password = ''
GROUP BY comment_post_ID
ORDER BY comment_date_gmt
DESC LIMIT 10";//3.输出10篇文章
$comments = $wpdb->get_results($sql);
foreach ($comments as $comment) {
$output .= "\n<li><a href=\"" .get_permalink($comment->ID)."#comment-".$comment->comment_ID. "\" title=\"" . $comment->post_title ."(". $comment->comment_count."评论)\">" . $comment->post_title . "</a></li>";
}//4.输出最近评论过的文章
$output = '<h3><span>'.get_avatar($comment,$size='16'). mb_substr(strip_tags($comment->comment_author),0,12).'</span>您最近还阅读过:</h3><ul>'.$output.'</ul>';
//5.标题格式为:头像+作者+文字
$output = convert_smilies($output);
echo $output;
}
?>