How to display recent posts outside WordPress

As fantastic as WordPress is, it can often be installed alongside an existing static website, rather then be used exclusively as a root CMS. The great news is that with a little PHP, you can access your WordPress installation’s Loop and fetch your posts.

Before you use the PHP code, make sure your page or template file is saved with the .php extension rather than .html etc. Assuming your WordPress installation is in a sub-directory called ‘WordPress’, copy and paste the following code onto your page:

If the WordPress folder has been renamed and/or at a different path, simply adjust the path to wp-load on line 3. You can also adjust how many posts are brought out on line 4, by changing the number next to ‘showposts’.