Is it possible to two way sync a post type between multiple sites on a multisite install? For example if someone makes a change to an entry under post type "inventory" on Site A how can I make that reflect on Site B automatically and vice versa?
Changes cannot show in Site C or Site D due for privacy reasons.
I am thinking that there are two main possible way of doing this, neither of which I'm sure can easily be done.
1) A plugin hooks into the edit_post so when a change is made the plugin edits the sister entry in the other blog's database table.
2) Anytime Site B views or edits an "inventory" post type it is reading it from Site A's database table.
While a setup and forget solution would of course be best I am open to a manual hack.
This was originally a [[LINK href="http://wordpress.stackexchange.com/questions/8142/two-way-synchronizing-of-a-post-type-among-multisite-blogs"]]Stack Exchange question[[/LINK]].
<strong>Edit: I understand that a solution may be more than $25. If you can tell me how you will get to a solution pm me and we discuss further details.</strong>
John Cotton answers:
I think you'd need to use two hooks: wp_insert_post to grab the post first time around and create it in the other blog table(s). Then store the post id and blog id of the original post in the post_meta of the second (to act as a foreign key).
Then use the post_updated hook to update the contents.
You'd need to check in the wp_insert_post that the post id didn't exist in your target tables as it gets fired both times.
PS I'm happy to write you a plug-in in that does this, but it's a bit more than $25 worth... :)
Sébastien | French WordpressDesigner answers:
For 25$ i have this solution : make a site xxx with the category inventory and display the content of this site in your site A and in tour site B
Using the switch_to_blog() function
do you want more info ?
Joachim Kudish answers:
Yes hooking into the insert and update hooks would be a way to go about it. However it would be much easier to simply display the post from site A within site B.
Using the switch_to_blog() function you can do just that http://codex.wordpress.org/WPMU_Functions/switch_to_blog , while using it you can use any normal WordPress query functions to get your posts.
Note, using this function isn't recommended when you have more than a dozen sites or more then a few hundread posts as it can get quite heavy performance wise. Then again, almost every method of doing this will be resource heavy.
Another way to do it, which to me is a bit weird but would still work, would be by pulling the RSS feed from site A in site B.
In any case, try to use a caching plugin such as Super Cache or W3TC to help with performance.
Let me know if you have more questions
Matt Taylor comments:
Each site pair will have between 50 and 300 active entries at any one time. Do you think that is too much load for switch_to_blog()?
Joachim Kudish comments:
There is no secret number to how many posts will be supported. If you have a decent server than 300 posts should be okay. If you have a cheap shared host, then you may have a harder time. Again, using caching will help.