Latest headlines window on home page
-
Hi there, I’ve spotted this nice site https://www.finisterreuk.com/newsletters/ which uses wordpress, I want to emulate the little latest posts window at the top left, what is the easiest way to pull a list of say 5 recent posts from wordpress onto a static page with links?
Hope somebody can help, I’m currently trying this
<?php
$how_many=5; //How many posts do you want to show
require_once(‘wp-config.php’); // Change this for your path to wp-config.php file ?><ul class=”whats-new”>
<?php
$news=$wpdb->get_results(“SELECT ID,post_title FROM $wpdb->posts
WHEREpost_type
=\”post\” ANDpost_status
= \”publish\” ORDER BYpost_date
DESC LIMIT $how_many”);
foreach($news as $np){
printf (”- %s
“, $np->ID,$np->post_title);
}
?>But just getting an empty unordered list right now.
Thanks
- The topic ‘Latest headlines window on home page’ is closed to new replies.