As soon as i configure ah_recent_posts that way, the output comes out blank.. nothing is displayed.
here's the code with get_blog_permalink.
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 ID, post_title, post_content, user_email
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);
$permalink = get_blog_permalink( $blog, $thispost[0]->ID );
// get authors gravatar
$avatar = get_avatar( $thispost[0]->user_email , 48 );
// 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>
'.$avatar.'
<h2><a href="'.$permalink.'">
'.$thispost[0]->post_title.'</a></h2>
'.$shortDesc.'
<a href="'.$permalink.'">[...]</a>
</li>';
$counter++;
}
// don't go over the limit
if($counter >= $how_many) {
break;
}
}
}
}
?>