How to Display Posts Outside of WordPress
- 1). Copy and paste the following code into your non-Wordpress website:
<ul>
<?php require($_SERVER['DOCUMENT_ROOT'] . '/wordpress/wp-load.php'); query_posts('showposts=3'); if (have_posts()) : while (have_posts()) : the_post(); ?>
<li>
<h2><a href="/links/?u=<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<span>Posted on <?php the_time('l jS F, Y') ?></span><br />
<?php the_excerpt(); ?>
</li>
<?php endwhile; else: echo "no posts"; endif; ?>
<?php wp_reset_query(); ?>
</ul> - 2). Change the path to wp-load in line to of the code if your folder is different from "wordpress." A path points to the location of your file. For example, if your folder is "myfiles" change the code to "<?php require($_SERVER['DOCUMENT_ROOT'] . '/myfiles/wp-load.php'); ".
- 3). Change "showposts" to reflect the number of posts you want to display. For example, if you want to show 5 posts at a time then change the code to read "('showposts=5')".