I have a WP Multisite :
1 main domain not accessible in front-end, and 20 public sub-sites ; If a visitor query the main domain, a geo-ip resolution redirects him to the most appropriate sub-site.
I have a custom post type which is global : all datas must be displayed on all sub-sites. Today, I have a sync process which copies all datas (post + postmetas + related taxonomies) to all sub-sites. This process works, but is very slow and consumes a lot of resources ; furthermore, it's stupid to duplicate same datas across all sub-sites so I try to do in an other way.
I think about using the posts_request
filter ; I check what object is queried, and if its my global CPT, I replace the table prefix with the prefix of the main domain.
I know it will be complicated to adapt all the queries (for example if several cpt are queried, with tax relation...) ; I know I will need to adapt the search queries. But there is also advantages : No more duplication/synchronization of datas.
For now, my search&replace works as expected and entries of main site are well displayed on the sub-sites (on front & back office). I have a bug for the edit-link which of course is not valid on sub-sites : redirects to current sub-site, but with post_id of the main-site... (I didn't decided yet if I disallow this CPT edition on sub-sites or if I change this edit-link to redirect to main-site in case of editing.)
My question is :
With your experience, can this method work? What big bugs could I have?