Return to Snippet

Revision: 30939
at August 26, 2010 00:03 by bronet


Updated Code
<?php
  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
  // pay atention on the include path if you want to work :-)
  
  echo '<h3>Recent Blog Post</h3>';
  echo '<ul>';
  $number = 3; // number of recent posts that you want to display
  $recent_posts = wp_get_recent_posts($number); // this function will display recent posts, order by ID DESC
  foreach($recent_posts as $post){
    echo '<li><a href="'.get_permalink($post["ID"]).'">'.$post["post_title"].'</a></li>';
  }
  echo '</ul>';
?>

Revision: 30938
at August 25, 2010 23:53 by bronet


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

Initial URL


Initial Description
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/

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

Initial Tags
wordpress

Initial Language
PHP