Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

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

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
Thanks!! chdir() did it. One odd thing is that the permalink for the post is an instance variable called "guid" (i.e. $post->guid)... odd. And not in the official docs for get_posts (codex.wordpress.org/Template_Tags/get_posts) -- should I be alarmed at this? –  Eric Mar 9 '12 at 19:36
1  
Glad it helped. Use get_permalink( $post->ID ) instead of guid, Note: One cannot rely upon the GUID to be the permalink (as it previously was in pre-2.5), from codex.wordpress.org/Function_Reference/get_post. –  soulseekah Mar 9 '12 at 19:43
add comment

there's a slight different version of Soulseekah's one that seems a bit better

i found it here Get user info outside Wordpress

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.