Posted By

kwilson on 04/16/09


Tagged

php wordpress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

fabi


Display 5 latest Wordpress posts


 / Published in: PHP
 

Grab 5 latest Wordpress posts and display them on a non-Wordpress PHP page.

  1. <?php
  2. // Include Wordpress
  3. define('WP_USE_THEMES', false);
  4. require('./blog/wp-blog-header.php');
  5. query_posts('showposts=5');
  6. ?>
  7.  
  8. <ul>
  9. <?php while (have_posts()): the_post(); ?>
  10. <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
  11. <?php endwhile; ?>
  12. </ul>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: kwilson on April 16, 2009

Be sure to adjust line 4 to reflect the actual location of your Wordpress directory.

You need to login to post a comment.