Support » Plugins and Hacks » Hacks » One page showing on two sites

One page showing on two sites

  • I’m working on two separate websites for business partners – one is a home builder, and one is a realtor who sells the homes. The realtor isn’t very likely to update his own site, so he wants the home listings that are updated on the home builder’s site to automatically update on his site – basically I need to show the same page on two separate sites. Is there a way to do this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz


    I’ve no idea if this would work, but may be worth some minimal testing to see if it’s worth pursuing. All DB access ends up being channeled through the connection contained in the global $wpdb object.(I think) I could see creating a second DB object on the realtor site that connects to the builder’s site’s DB. A switcher function would have the ability to store both DB objects and on call assign either one to $wpdb. The realtor’s theme’s templates would be smart enough to know which DB object it needs for certain content and calls the switcher as needed before querying for content. Otherwise, all business as usual.

    That sounds like it’s worth a try. I don’t have very much experience working with databases, do you know of any good sites you’d recommend looking at that might be able to help me figure that out?

    Moderator bcworkz


    The beauty of my idea is you don’t need to know much of databases. You would be essentially be fooling WP into doing what it does normally, except it is unknowingly actually connected to a different database. If this idea fails, then you probably will need to start learning about databases as you will be managing access to the second database with your own code.

    I’m sorry I can’t suggest any good resources for pulling this off. The first thing you should focus on doing is creating a database object equivalent to the global $wpdb. ($wpdb is instantiated in require_wp_db() which is defined in wp-includes/load.php.) Then see if you can swap yours for the original and do a get_posts() from the second database without WP having a fit. If you can do that, I’d say this is a viable project.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘One page showing on two sites’ is closed to new replies.
Skip to toolbar