************************************************** Stuff to add to index (Latest is just a container div to keep it all neat) **************************************************
************************************************** Stuff to add to your normal wordpress stylesheet ************************************************** #latest { padding-top:5px; font: bold 11px/13px Verdana, sans-serif; padding-left:1px; padding-right:1px; .latcomment { border-left: solid 0px #ff0000; border-right: solid 0px #ff0000; border-top: solid 0px #ff0000; border-bottom: solid 0px #E8E8E2; padding:2px; background-color: #F9F9F7; } .activityentry { font-weight:bold; font-size:12px; background-color:#EFEFE9; padding:2px; } ************************************************** Replacement brianslatestcomments.php follows below (Backup first!!) (To be honest I can't remember if I did change this much.) ************************************************** Michael Heilemann.
If you have Dunstan's Time Since installed, this plugin uses it for the title="" attributes on the comments and posts. (For WordPress 1.5) Author: Brian Meidell Author URI: http://meidell.dk/blog Version 1.5: Now works without LOCK TABLE and CREATE TEMPORARY TABLE priviledges. */ function blc_latest_comments($num_posts = 5, $num_comments = 6, $hide_pingbacks_and_trackbacks = true, $prefix = "", $postfix = "
") { global $wpdb, $tablecomments, $tableposts; $usetimesince = function_exists('time_since'); // Work nicely with Dunstan's Time Since plugin (adapted by Michael Heilemann) // This is compensating for the lack of subqueries in mysql 3.x // The approach used in previous versions needed the user to // have database lock and create tmp table priviledges. // This uses more queries and manual DISTINCT code, but it works with just select privs. if(!$hide_pingbacks_and_trackbacks) $ping = ""; else $ping = "AND comment_type NOT LIKE '%pingback%' AND comment_type NOT LIKE '%trackback%'"; $posts = $wpdb->get_results("SELECT comment_post_ID, post_title FROM ($tablecomments LEFT JOIN $tableposts ON (comment_post_ID = ID)) WHERE comment_approved = '1' $ping ORDER BY comment_date DESC;"); $seen = array(); $num = 0; foreach($posts as $post) { // The following 5 lines is a manual DISTINCT and LIMIT, // since mysql 3.x doesn't allow you to control which way a DISTINCT // select merges multiple entries. if(array_key_exists($post->comment_post_ID, $seen)) continue; $seen[$post->comment_post_ID] = true; if($num++ > $num_posts) break; $commenters = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_approved = '1' AND comment_post_ID = '".$post->comment_post_ID."' ORDER BY comment_date DESC LIMIT $num_comments;"); $count = $wpdb->get_var("SELECT COUNT(comment_ID) AS c FROM $tablecomments WHERE comment_post_ID = $post->comment_post_ID"); $i = 0; $link = get_permalink($post->comment_post_ID); echo $prefix."
".stripslashes($post->post_title). "
\n"; if($usetimesince) $title = " title=\"Last comment was ".time_since($comment->unixdate)." ago\""; foreach($commenters as $commenter) { if($usetimesince) $title = " title=\"Posted ".time_since($commenter->unixdate)." ago\""; if($i++ > 0) echo ", "; echo "comment_ID."\"$title>".stripslashes($commenter->comment_author).""; } if($count > $num_comments) echo " [...]"; echo "
".$postfix."
\n"; } } ?>