Installing too many plugins will make the wordpress blog work slowly and unstable, use code built in your theme will reduce the system resources.

Most recent post and comments
List most recent comments
<?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;
$output .= "\n<ul>";
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 .= "\n</ul>";
$output .= $post_HTML;
echo $output;
?>
If you want to list more or less comments, simply change the "10" in the $sql variable.
List most recent posts
<?php query_posts('showposts=5'); ?>
<ul>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
</ul>
Do you want to deactive your List most recent comments and recent post plugins then use code snippets above?












[... - http://www.narga.net is another useful authority of information. Making money online is [… -
Hi,
I cannot get this to work. “<a href="" = syntax error for me in Aptana Studio and I get the same result if I ignore that and try anyway
Can you help? Thanks
I recommend you using another code editor just as Notepad++, Notepad2 … or you can try notepad to edit that code
Hello:
Thanks for sharing the code for listing of comments. I have used it at indicpost.com/readers-zone/. You can see it after clicking the “Recent Comments” tab.
However, as you can see, the comments are NOT in the desired output. I want JUST ONE COMMENT PER LINE. Please guide me on the subject. Just for info, I am a journalist and not a techie.
Thanks in advance,
Best Regards,
Anshuman (from INDIA)
Because the output is unordered list, so you can style it by using CSS in your html code.
You can use
Hello:
Thanks a lot for your reply.
At the risk of antagonising you, I’m afraid I will have to ask you the basic question:
Where do I put “display: block;” in the following:
—————————————————–
Note: Click the name of the user to reach the exact news story where the comment was posted.
Recent Comments
<?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; $output .= "\n<ul>"; 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 .= "\n</ul>"; $output .= $post_HTML; echo $output; ?>—————————————————–
I am sorry but I am only a journalist and am learning the thing through trial and error only.
Thanking you in advance,
Best Regards,
Anshuman
very goods
You will get the HTML output is:
Everythings you need to do is create a CSS selector for that list.
Change the line 7th to:
Create CSS selector:
.recent-comment ul li { display: block; }