The key to gaining access to the power of Wordpress from an outside page lies in the wp-blog-header.php file. This file loads the Wordpress application and makes its API, and therefore your content, available for use. Once this file is included in a page on your site, you will be able to use any Wordpress function just as if you were working in a Wordpress template.
Let’s add the latest post to the front page of our site. We’ve already got a blog at www.example.com/blog/ but it would be nice to show the latest entry alongside the rest of the information on the front page. If your front page is already a PHP file, you’re ready to go; otherwise you’ll probably need to rename your front page file extension from .html to .php. (Be sure to test to ensure that doesn’t break anything!)
The first thing we’ll do is pull in that all-powerful Wordpress file, which we can do by adding this section to the very top of the page you want your post to appear on:
The first line of this block is simply a comment describing what we’re doing. The second line tells Wordpress not to display your templates, and the third line grabs that file I told you about. The final line performs a database query to retrieve the content we want to display on this page. In this example, we want the single most recent post, but the query_posts() documentation shows how to retrieve a variety of data.
Now we’ll move down in our page and find a good spot for this post. Once you’ve figure out where to put it, we’ll add a Wordpress loop which will display the single post retrieved above:
Once the loop is in place, we just have to decide what parts of the post to display, and write some HTML for them. Let’s say we want the post title and just an excerpt, followed by a link to the full article. We’d do something like this: