Page 1 of 1

Posting two Wordpress blogs on one page

Posted: Fri Jun 24, 2011 9:28 am
by jodmy
I am trying to intergrate two blogs into the same pages using the following code

Code: Select all

  <?php
// Include WordPress 
define('WP_USE_THEMES', false);
require('../../blog/wp-load.php');
query_posts('showposts=5');
?>    

<?php while (have_posts()): the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
<p><a href="<?php the_permalink(); ?>">Read more...</a></p>
<?php endwhile; ?>

<?php
// Include WordPress 
define('WP_USE_THEMES', false);
require('../../Company_Blog/wp-load.php');
query_posts('showposts=5');
?>

<?php while (have_posts()): the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
<p><a href="<?php the_permalink(); ?>">Read more...</a></p>
<?php endwhile; ?>

however it only brings up the posts from the first blog and I need the first 5 from both.

any ideas how I can run both scripts separately on the same page two display both blogs.

Re: Posting two Wordpress blogs on one page

Posted: Sat Jun 25, 2011 6:54 pm
by McInfo
The two copies of WordPress cannot share the same global scope without extensive refactoring, so that rules out includes. You need to step out to a broader scope, which means running each copy from separate HTTP requests. That could be done by using two iframes in your page (so the browser makes the requests) or by using PHP's file or cURL functions (so PHP makes the requests).