发新话题
打印

[问题求助] 如何在首页显示最新评论全文?

如何在首页显示最新评论全文?

http://www.kite.hi.cn/


我在widgets里添加了最新评论,但是首页只显示,“某人 发表于 某篇文章”,  没有显示评论全文。怎么让显示评论全文?谢谢!

TOP

某插件可以,论坛搜索一下
Slyar Home -- www.slyar.com

TOP

仔细看output部分的代码..

TOP

Simple Recent Comments
或者下面的代码
复制内容到剪贴板
代码:
<?php
$comments_count = 5; // 评论数
$comments_length = 30; // 评论长度

$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,
                SUBSTRING(comment_content,1,$comments_length) 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 post_password = ''
        ORDER BY comment_date_gmt DESC
        LIMIT $comments_count";
$comments = $wpdb->get_results($sql);

$output = "";
foreach ($comments as $comment) {
        $output .= "\n<div class=\"home_recent_comment\">";
        $output .= "<h4><a href=\"" . get_permalink($comment->ID) . "#comment-" . $comment->comment_ID  . "\">" . $comment->post_title . "</a></h4>";
        $output .= "<div><span>" . $comment->comment_author . "</span> says : " . strip_tags($comment->com_excerpt) . "...</div>";
        $output .= "</div>";
}

echo $output;
?>
找我吗?何必那么麻烦。

Hpyer 的未知空间就在:http://hpyer.cn

TOP

发新话题