Showing content from another wordpress installation database in the page template loop?

I am just wondering if it is possible to show just the page content of another wordpress database on wordpress pages with the same pageID within the content loop in my page template. To be more specific, I want to show the content of one separate wordpress database in another wordpress installation without duplicating it. Its just the page content I want to get, so no articles needed. The structure and page ids of the two wordpress installations are identical.

I want to adress the database using $wpdb but have no idea how to deal with that problem and if its possible to solve it at all?


edit: They are not the same domain. And thank you for commenting, kaiser! I want to have two separate, identical wordpress installations, sharing the page content of one single database, but keeping their individual local settings (local database), themes and styles. As I said, the structure of the sites (navigation, page IDs) is identical. In this case I use WordPress more like a CMS then a Blog System, and the media library is delivered via CDN, so media-content won’t be a problem in shared content.

My first idea was to get $wpdb in my page template to get the content of the external database. But this would mean to adress the page content by page ID, wouldn’t it?


edit2: Here’s what I tried today:

    <?php
    $wpdbtest = new wpdb('username', 'password', 'dbname', 'host');

    $query = "SELECT post_content, guid FROM myprefix_posts
        WHERE post_status = 'publish'
        AND post_type = 'page'";

    $myposts = $wpdbtest->get_results($query, OBJECT);
        foreach($myposts as $mypost)
        echo "{$mypost->post_content}";
    ?>

I put this code into my page template and I even got the post_content output. But as far as I am concerned, this is NOT what I was looking for. Shortcodes won’t be parsed and performance may be a problem too.

Do you guys know any possible way, to make wordpress parse shortcodes that were received out of an external database? As I said, the two wordpress installations are identical, so al shortcodes are well defined in each functions.php.

Thank you!

Solutions Collecting From Web of "Showing content from another wordpress installation database in the page template loop?"

On your edit2:

If it’s exactly the same, could you add

echo apply_filters('the_content', {$mypost->post_content});

to apply the_content filter to parse the shortcodes?

Also, why not use the multi-site feature of WordPress? If so much is identical, it seems more straightforward to update if your code is not duplicated. And for shared content you could then use get_blog_post(). You can still map to individual domains so you have your url differences.