I don't wanna use the widget or install a separate plugin so I wanna paste it in my sidebar.php file; but I can't figure out what the code will be
Errr...I might have gotten this wrong, but I'm pretty confident this will work. <div class="blockinner"> <h1>Recent Comments</h1> <?php $comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID, comment_content FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 4"); ?> <?php if ( $comments ) : foreach ($comments as $comment) : echo '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-'. $comment->comment_ID .'">'. get_comment_author() .'</a><br /><p>'. $comment->comment_content .'</p><div class="recentcommentsline"></div>'; endforeach; endif;?> </div> Code (markup): Amend the h1 and div's as appropriate Cheers
The PHP code looks correct, but I'd give the DIV an ID of "recent comments" and use a lower heading instead, but that's just me picking over semantics (it's what I do for a living).
Cheers for the tip Dan - I just ripped the code from a template I edited a bit last year...should still be good to go, though
Well it should be "recent-comments" not "recent comments" (I forgot to include the dash in there when I was writing the post).