views:

35

answers:

1

I am building a static site using php files. On the index.php file, I need to dynamically pull the RSS feed of a certain wordpress.com blog. The only information I need to pull is the excerpt content of the newest post (1 post total). When the wordpress.com blog is updated, the content on the index.php file should update to an excerpt of that newest blog post on wordpress.com.

I know how to do this with wordpress.org self-hosted blog (logging in to the wp-login.php file and adding the loop to the external index.php file), but unfortunately it doesn't work the same with wordpress.com blogs since they are automatically hosted.

+1  A: 

Magpie RSS is your friend. I use it a lot to grab the most recent entry via RSS an show it on another webpage. I've only used it with self-hosted Wordpress blogs, but since it's based on the RSS feed I see no reason why it wouldn't work from wordpress.com as well.

An example from their website:

require_once 'rss_fetch.inc';

$url = 'http://magpie.sf.net/samples/imc.1-0.rdf';
$rss = fetch_rss($url);

echo "Site: ", $rss->channel['title'], "<br>";
foreach ($rss->items as $item ) {
    $title = $item[title];
    $url   = $item[link];
    echo "<a href=$url>$title</a></li><br>";
}
Chris Arguin
Hi Chris, that's an interesting script except I don't know the syntax to grab the content and not just the title. Do you know where I can learn the syntax to pull the content? I'm a total newb at this kind of stuff so I need to learn!
Micah
Newb at PHP or Magpie?
TheDeadMedic
Well, both really. Because I've worked with Wordpress and custom PHP scripts over the years, I'm decent at editing the syntax of PHP but I still consider myself a relative newb at programming in general. Yet, with magpie, I have zero experience.Since I wrote the above, I've managed to figure out to replace "title" with "description" and it'll pull the excerpt content, however I'm not sure how to separate paragraphs if the excerpt contains two short sentences from two different paragraphs. I also don't know how to make only the ending [...] linked and not the paragraph itself.
Micah