I have a multi-site setup as follows

Main Site has no posts
Site A has 1 post A
Site B has 1 post B
Site C has 1 post C

What I'm interested in is to be able to treat the main site as an aggregation of each of the subsites, so that when users visit Main Site, they will see

Post A
Post B
Post C

And in the Posts dashboard, I would see the three posts as well.

The first solution I had in mind was to just duplicate posts from each site to the main site by hooking onto add post, edit post, etc. so that when something is changed, it would also change the post on the main site. But that seems redundant.

When I look at the database, I can see that each site is actually just prefixed with a number. From here what I'm thinking is I could

  1. grab a list of sites by querying the blogs table
  2. given each prefix, query all posts from the respective table
  3. take the union of all results

So basically when you request a list of posts from the site, it doesn't pull its own posts but instead pulls posts from other tables in the database.

However I've been going through the code but I can't figure out where the queries are actually being performed, and subsequently whether there's any hooks I can use to change the results.

Any direction would be great.

1 Answer 1


There are ways to loop through all the sites in a multisite, then do a "WP Loop" on each sub-site. It can get a bit complex, but it can be done.

I did some research on this, and found some code fragments that would do it, but no full-on solution. So I wrote my own plugin (called "Multisite Post Reader", available in the repository) that does that very thing. It has lots of options for filtering what is displayed.

Although plugins aren't supposed to be recommended here, it might server your needs. At the least, you could dig out the code and modify it for your own needs. (The code is a bit long to post here.) Although you get a 'version warning' from the repository, it does work with current WP versions.

I wrote a similar one for images across multisites. I've been working on combining the two into one plugin, but it's a low priority on my worklist.

  • Thanks for the response. I'll take a look at the code and see if it'll give some hints towards a solution that works for me.
    – MxLDevs
    Oct 20, 2020 at 20:00

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.