Figured it out.
final code:
save as ah-recent-posts-mu.php
Use
<ul>
<?php ah_recent_posts_mu(10) ?>
</ul>
to call in your home.php or wherever and set positioning with CSS. This will output the recent posts that are not private, spam, etc. It will also display 12 words from the content and gravatar size is to 64...so change that how you want. Hope this helps some future noob like me :)
<?php
/*
Plugin Name: WordPress MU Recent Posts
Plugin URI: http://atypicalhomeschool.net/wordpress-plugins/
Description: Retrieves a list of the most recent posts in a WordPress MU installation. Based on (Andrea - fill this in)
Version: 0.3
Author: Ron Rennick
Author URI: http://atypicalhomeschool.net/
Use this by pasting the following wherever you want it to show:
<?php ah_recent_posts_mu(10) ?>
*/
function ah_recent_posts_mu($how_many = 10) {
global $wpdb;
$counter = 0;
// get a list of blogs in order of most recent update
$blogs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs WHERE
public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated >= DATE_SUB(CURRENT_DATE(), INTERVAL 5 DAY)
ORDER BY last_updated DESC");
if ($blogs) {
foreach ($blogs as $blog) {
// we need _posts and _options tables for this to work
$blogOptionsTable = "wp_".$blog."_options";
$blogPostsTable = "wp_".$blog."_posts";
$options = $wpdb->get_results("SELECT option_value FROM
$blogOptionsTable WHERE option_name IN ('siteurl','blogname')
ORDER BY option_id, option_name DESC");
// we fetch the title and link for the latest post
$thispost = $wpdb->get_results("SELECT post_title, guid, post_content, post_date, user_email, user_login
FROM $blogPostsTable, wp_users
WHERE wp_users.ID = $blogPostsTable.post_author
AND post_status = 'publish' AND post_type = 'post' AND post_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 5 DAY)
ORDER BY $blogPostsTable.id DESC limit 0,3");
// if it is found put it to the output
if($thispost) {
// pull in the posts content from database
$desc = $thispost[0]->post_content;
// save the post date to a var
$date = strtotime($thispost[0]->post_date);
// strip out html characters to allow for truncating
$strippedDesc = strip_tags($desc);
$avatar = get_avatar( $thispost[0]->user_email , 64 );
// truncate post content to 12 words
$numwords = 12;
preg_match("/([\S]+\s*){0,$numwords}/", $strippedDesc, $regs);
$shortDesc = trim($regs[0]);
// Displays the post title url truncted text and soon author
// Author currently returns the ID (number) I will have to compare this to display_name and return a string name...
echo '<li><h2><a href="'.$thispost[0]->guid.'">
'.$thispost[0]->post_title.'</a></h2>
'.$shortDesc.'
'.$avatar.'
<a href="'.$thispost[0]->guid
. '">[...]</a>
'.$thispost[0]->user_login.'
</li>';
$counter++;
}
// don't go over the limit
if($counter >= $how_many) {
break;
}
}
}
}
?>