1

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?

1 Answer 1

0

OK this is a longshot, but what if These network wide posts had their own subdomain for entry and then you access / display them on sub sites with switch to blog. I personally use this on one of my projects to handle some kinde of pseudo membership for multisite and to display network wide banners.

All in all, this topic interests me also, so I'm looking forward to see other opinions.

Your Answer

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

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