Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Small multisite setup, two very different sites, both need to access an event custom post type. I don't want to duplicate posts (there are some plugins that "broadcast" a post to the network).

switch_to_blog(1) will get me part way there, where blog 1 is the "master" blog that contains the event data, as far as archive-style pages that list all the events. But my concern is that the URL/permalink of the event, when viewed from blog 2 will point to blog 1, and following that permalink will then take the user to the other blog, confusing the user.

Is there a solution (possibly using rewrite) that would allow an event post at //blog1/events/event1 to appear as //blog2/events/event1 when viewed from blog 2?

share|improve this question
    
You might want to take a look here - wordpress.stackexchange.com/questions/11276/… - that would be a different approach. –  ialocin Jun 5 '13 at 14:10
    
I've already been there, and that's why I created this question specifically. Thanks for the comment though. –  Tom Auger Jun 5 '13 at 15:21
add comment

2 Answers

There are two options:

  1. Register the CPT on blog 2 with 'show_ui' => FALSE. Hook on blog 1 into save_post and copy the data to blog 2.

    • Pro: You can search in those posts. Correct templates will be used automatically.
    • Con: Duplicated data are always a little bit … dirty.
  2. Register an endpoint with an URL scheme like the CPT on blog 1 (EP_ROOT).

    • Pro: No duplicated data.
    • Con: You have to implement the template logic manually to load the correct theme file. And search will not work.
share|improve this answer
add comment

Decide which blog will contain the "data of record", use "show_ui" => false on the other blog(s) and then modify queries that deal with that post to use the appopriate table prefix. The data will still be populated within the context of whatever blog you're viewing (ie: site_url() will work as expected, and your templates and theme will be correct - assuming you're using different templates and themes for different blogs), and you won't have duplicated data anywhere.

The downside is that in a scenario with a very large network of blogs, this might become unmanageable.

It also means that you must have access to the "blog of record" in order to be able to enter and update the post data, unless you're also prepared to hook into the save_post action of all the other blogs and fool them into writing the data to the other blog's tables. You would then also need to fudge that post type's List Tables and edit-post request as well, which is daunting to say the least.

This solution works in the case of a piece of content that will be maintained by an administrator with access to the primary blog, but needs to be posted to or visible on other blogs on the network; it is not appropriate for content that will be created by admins/users of other blogs on the network to be shared with the other blogs on that network. For that approach, see toscho's answer here.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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