/ 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/
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?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>'; ?>