Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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