Multiple WordPress outside wordPress installation?

I have a main page where i want to show up the latest post content of two or more blogs.. for now I have this code :

    <?php
    // Include WordPress Blog 1
    define('WP_USE_THEMES', false);
    require('./blog1/wp-load.php');
    ?>  
    <?php query_posts('showposts=3');?>
    <?php while (have_posts()): the_post(); ?>
        some of my blog 1 stuff.. .
    <?php endwhile; ?>
    <?php wp_reset_query();?>

    <?php
    // Include WordPress Blog 2
    define('WP_USE_THEMES', false);
    require('./blog2/wp-load.php');
    ?>  
    <?php query_posts('showposts=3');?>
    <?php while (have_posts()): the_post(); ?>
        some of my blog 2 stuff.. .
    <?php endwhile; ?>
    <?php wp_reset_query();?>

blog no. 1 is showing it’s content but blog no. 2 doesn’t show up the content.. .how can I reconstruct them both to work in one page which is my main page… are this possible to reconstruct?

Related posts

Leave a Reply

2 comments

  1. I highly doubt you can get it to work that way reliably. WordPress relies a lot on global variables and so there is no way you can keep two WordPress instances active and sane at the same time.

    My suggestion would be to use RSS feeds of posts from those two blogs (with RSS widget or fetch_feed()) or direct SQL queries.

  2. The second wp-config.php file isn’t getting loaded, for starters. 🙂

    Even if you worked around that, though, it doubt you’ll get it to work, because globals, constants and included files will be those of the first install.

    You could arguably reset key globals ($wpdb and and $wp_object_cache in particular). Extensive amounts of filters might allow you to work around key defines (e.g. WP_CONTENT_DIR). The theme’s functions.php and the plugins files, if they differ on the two sites, are another story entirely.