WordPress display the latest comment
<?php
global $wpdb;
$sql = βSELECT DISTINCT ID, post_title, post_password, comment_ID,
comment_post_ID, comment_author, comment_date_gmt, comment_approved,
comment_type,comment_author_url,
SUBSTRING(comment_content,1,30) 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 10β³;
$comments = $wpdb->get_results($sql);
$output = $pre_HTML; foreach ($comments as $comment) {
$output .= βn<li>β.strip_tags($comment->comment_author)
.β:β . β <a href=ββ . get_permalink($comment->ID) .
β#comment-β . $comment->comment_ID . ββ title=βon β .
$comment->post_title . ββ>β . strip_tags($comment->com_excerpt)
.β</a></li>β;
} $output .= $post_HTML;
echo $output;?>