I'm using this PHP code to display the most recent post from a Wordpress blog on a separate, static, non-Wordpress page. The blog and static page are part of the same site. The code works fine for one blog.
<?php
$how_many=1; //how many posts to display
require('blog1/wp-config.php'); //the path to the wp-config file of the blog I want to use
?>
<?
$news=$wpdb->get_results("SELECT 'ID','post_title','post_content' FROM $wpdb->posts
WHERE 'post_type'=\"post\" AND 'post_status'=\"publish\" ORDER BY post_date DESC LIMIT $how_many"); ?>
<?
foreach($news as $np){
printf ("<div class='normalText'>%s</div>", $np->post_content);
}?>
The code isn't of my own creation; I've just edited it a little. I'm not very familiar with PHP, so I'm not sure why when I try the same thing twice on one page, with different blogs (i.e. once as above, then once again later in the page with "blog2/wp-config" rather than "blog1/wp-config"), it won't work. In fact, it simply displays (twice) the first post from whichever blog I refer to in the first section of code.
I have managed to display what I want, by putting the code for each blog excerpt in its own webpage, and then using iframes to display all of them on the main page. However, any advice toward achieving a neater solution would be much appreciated!
Thanks a lot!