How can I get a list of latest posts outside of my WP install?

You have several options.

XML-RPC

http://codex.wordpress.org/XML-RPC_Support is the place to start. The API exposes a large number of methods to access WordPress data “outside” of the full WordPress context. Difficult to setup, connection requests overhead.

wp-load.php

Include wp-load.php to load up WordPress. You will need to chdir() into WordPress first for this to work properly, depending on your environments and contexts. Easy.

chdir( 'wordpress' );
require( 'wp-load.php' );
foreach ( get_posts() as $post ) {
    echo "<h2>{$post->title}</h2>";
}

This is very similar to the link you posted. The error you’re getting is probably an include that is relative to some path. So change directories before and after.

XML feeds

Parsing the feed may be overkill, unless you cache maybe. Highly discouraged.

Leave a Comment