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

I have a site with WP installed at /blog, and I’d like to just get a list of the latest blog posts to display on the site home page… that is to say, my custom (PHP) home page, NOT a WordPress page.

I found this, but it doesn’t work– the latest version of WordPress is looking for Translate_Entry.php or some other kind of class that it can’t find.

Read More

Is there an easy way to do this, short of picking up and parsing the RSS feed on the fly?

Related posts

Leave a Reply

2 comments

  1. 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.