Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to get the recent comments on all posts in a multisite network, and I want to display these ceomments in a sidebar on the multisites "mother" blog. To complicate: All blogs are forced to post in either category A or category B. I want two outputs on the mother blog, showing comments on posts in category A and a second output for comments posted in category B. Question: Is this possible?

share|improve this question
    
I answered a similar questions some days ago. Maybe this is useful too: Quering post from multisite network –  realloc Dec 11 '12 at 12:54
add comment

2 Answers 2

Well it is quite possible, when using a multisite you have a few extra tables in your database. One of them is one that is called wp_site which has inside it a list of all your blogs. It looks something like

site_id | blog_id | some other vars ...
1         1         ...
1         2         ...
1         3         ...

You would have to fetch all of these, and then you could fetch all other posts comments using the $wpdb->get_results more or less like so,

foreach ($blogs as $blog) {
  $blog_comments = $wpdb->get_results("SELECT c.*, p.* FROM wp_{$blog->blog_id}_comments AS c INNER JOIN wp_{$blog->blog_id}_posts AS p ON c.comment_post_ID = p.ID ORDER BY comment_date DESC LIMIT 0,10"); // Get the latest 10 comments from each blog and it's related post
}

Afterwards you would need to check for the posts category and post it on the front side accordingly.

If you need more help, comment here, I'll try to supply more data.

share|improve this answer
    
oh... I didn't expect anyone to reply..! thank you! I am going to try out this later on today! –  John Olav Oldertrøen Dec 10 '12 at 14:49
    
Why not use a native WP function? For getting all the blogs, yes, it has to be via $wpdb, there's no alternative... –  brasofilo Dec 12 '12 at 21:55
    
so, did it work for you? –  gmaliar Dec 13 '12 at 12:07
add comment

There are quite a bit of plugins available to do this for you, a quick Google search will get you there.


Bloglist, recent posts and comments from the whole network.

Can be found here.


A central area where all the posts on a WordPress MU or WordPress MS site can be collected.

Can be found here.


A list of premium plugins (one matching your exact requirement) can be found here.
There are quite a bit more, free and premium, but I can only add some many links to this answer.

Hope this helps,

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.