Sunday, July 7, 2013

How to Run a Loop Outside of your WordPress website

First you must includes WordPress basic functions:

  // Include WordPress
define('WP_USE_THEMES', false);
  global $wpdb;

And then run your loop on any PHP file even OUTSIDE your WordPress website.

<?php while (have_posts()): the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
<p><a href="<?php the_permalink(); ?>" class="red">Read more...</a></p>
<?php endwhile; ?>
Disqus Comments