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?


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.

  • oh... I didn't expect anyone to reply..! thank you! I am going to try out this later on today! Dec 10, 2012 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, 2012 at 21:55
  • so, did it work for you?
    – gmaliar
    Dec 13, 2012 at 12:07

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,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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