[wp-hackers] recent comments

Ying Zhang meow at regretless.com
Tue Aug 17 20:04:54 UTC 2004


hi, i modified the recent comments hack from somewhere. here's my
function

/* recent comment modifiedy by dodo */
function print_recently_commented($num_posts = 5, $before="<ul>\n<li>",
$after="</li>\n</ul>", $between="</li>\n<li>", $show_pass_post = false)
{
	$num_posts = abs($num_posts);
	global $wpdb, $tablecomments, $tableposts;
	$request = "SELECT ID, post_title, comment_ID, comment_content, comment_author, comment_date FROM $tableposts, $tablecomments WHERE posts.ID=comments.comment_post_ID AND comments.comment_author != 'dodo' AND post_password ='' AND comment_approved='1' ORDER BY comments.comment_date DESC LIMIT $num_posts";
	$posts = $wpdb->get_results($request);
	$return_string = "";
	
	// If $before, $after, or $between is defined, then output HTML.
	$count = count($post_ids);

	$return_string .= $before . "\n";
	$i = 0;
	foreach ($posts as $post) {
		$i++;
		$title = stripslashes($post->post_title);
		$date = date('m/d/Y at h:iA', strtotime($post->max_comment_date));
		$author = $post->comment_author;
		$content = $post->comment_content;
		if(strlen($content) > 100) {
			$content = substr($content, 0, 100);
		}
		$return_string .= $author." - ";
		$return_string .= '<a title="'.htmlspecialchars(strip_tags(stripslashes($content))).'" href="' . get_permalink($post->ID) . '#comment-"'.$post->comment_ID.'>' . $title . '</a><br />' . "\n";
		//echo $date;
		if ($count > 0 && $i < $count) $return_string .= $between;
	}
	$return_string .= $after . "\n";

	echo $return_string;
} //end print_recently_commented()

the funny thing is $post->comment_ID is an empty variable.. why is
that??
-- 
http://regretless.com




More information about the hackers mailing list