WordPress.org

Ready to get started?Download WordPress

Forums

One page showing on two sites (4 posts)

  1. mollycampbell14
    Member
    Posted 1 year ago #

    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?

  2. bcworkz
    Member
    Posted 1 year ago #

    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.

  3. mollycampbell14
    Member
    Posted 1 year ago #

    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?

  4. bcworkz
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.