Posting two Wordpress blogs on one page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jodmy
Forum Newbie
Posts: 1
Joined: Fri Jun 24, 2011 9:22 am

Posting two Wordpress blogs on one page

Post 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.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Posting two Wordpress blogs on one page

Post 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).
Post Reply