I use the following function in the theme’s functions.php to correct the comment count on my Sitewide Tags blog.
function ds_sitewide_tags_get_comments_num($count) {
global $blog_id, $wpdb, $post;
$tags_blog_id = get_site_option( 'tags_blog_id' );
if( !$tags_blog_id || $blog_id != $tags_blog_id ) return $count;
list( $post_blog_id, $post_id ) = explode( '.', $post->guid );
$base = $wpdb->get_blog_prefix( $post_blog_id );
$r = $wpdb->get_col( "SELECT comment_count FROM {$base}posts WHERE ID=$post_id" );
if( is_array( $r ) ) return $r[0] + $count;
return $count;
}
add_filter('get_comments_number', 'ds_sitewide_tags_get_comments_num');
Now, that doesn’t get the actual comments to the main blog, but I don’t need them to. Any post link on the main blog takes reader to the original blog where the comments show normally.
I use a comment indexer(in mu-plugins) that dupes every comment in the network into its own site_comments table: http://pastebin.com/DDvbJFDb
Add to the comment indexer a function to display the comments: http://pastebin.com/qa1L47ky
Then I need only the following snippet anywhere in the network in any theme to show a list of recent comments collected from every post and every site:
<?php
display_recent_comments(10,150,'<ul>','</ul>','<li>','</li>');
?>
Remind me to buy you dinner. 😉
David –
Do I just copy and past the code from the first pastebin link into a new php file? Is there more to it?
Also, where in my theme should I put:
<?php
display_recent_comments(10,150,'<ul>','</ul>','<li>','</li>');
?>
Thanks, very much, in advance.