• Hello,

    I’ve been using this bit of code to display recent comments in my themes:

    function recent_com() {
     	global $wpdb;
    
    	$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,100) 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 DESC LIMIT 4";
    
    	$comments = $wpdb->get_results($sql);
    
    	foreach ($comments as $comment) {
    		$output = '<li>';
    		$output .= '' . strip_tags($comment->comment_author) . 'on - ';
    		$output .= '<a href="' . get_permalink($comment->ID) . '">' . strip_tags($comment->post_title) . '</a>';
    		$output .= '<span>'.strip_tags($comment->com_excerpt).'</span>';
    		$output .= '</li>';
    	}
    
     	echo $output;
    }

    … unfortunately, it doesn’t seem to work the same in version 3.0 – it only display one comment regardless on what I put as a LIMIT. It also displays different comment every time I change the limit number – seems like it displays 10th, 4th etc last comment except 10/4 of them.

    Has anything changed in version 3.0 that requires changing this bit of code?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[WP 3.0 RC] Recent comments code snippet?’ is closed to new replies.