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
- grab a list of sites by querying the
blogs
table - given each prefix, query all posts from the respective table
- 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.