We have two WordPress sites (Site 1 and Site 2) in the same database, with different prefixes ("site_1_" and "site_2_").

Let's say we've got a custom post type named "stuff", which is in Site 1. We'd like to use the same content for this particular post type in Site 2, while avoiding duplicated data.

I've played around with $wpdb->set_prefix(), but as we're also using WPML it gets a bit complicated, and doesn't feel like a bullet-proof solution.

Any suggestions? Or should I simply give up and use duplicated data anyway?

Thank you in advance.


If you intend the process to be portable, then don't use the database. Modify the theme to reply with either raw-html or php-serialized data and just do an http crossload.

If this is a one-time install and you don't care at all about portability, then just hardcode the query.

I've done both at one point or the other, there isn't much difference in implementation time. The queries occasionally have to be redone after an upgrade.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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