Posted By

bronet on 08/25/10


Tagged

wordpress posts recent


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

techdetours
mikoli
booski


Pulling posts from outside wordpress (in the right way!)


 / Published in: PHP
 

Pulling posts from outside wordpress (in the right way!) as a response for this snippet: http://snipplr.com/view/39523/pulling--posts-from-outside-wordpress/

  1. <?php
  2. include('wp-load.php'); // it is neccesary to include wp-load.php, cause it's the only why to use Wordpress API outside of Wordpress
  3. // pay atention on the include path if you want to work :-)
  4.  
  5. echo '<h3>Recent Blog Post</h3>';
  6. echo '<ul>';
  7. $number = 3; // number of recent posts that you want to display
  8. $recent_posts = wp_get_recent_posts($number); // this function will display recent posts, order by ID DESC
  9. foreach($recent_posts as $post){
  10. echo '<li><a href="'.get_permalink($post["ID"]).'">'.$post["post_title"].'</a></li>';
  11. }
  12. echo '</ul>';
  13. ?>

Report this snippet  

You need to login to post a comment.