Most Recent Post Titles on Static Page
-
I am trying to display the titles of my most recent posts in the sidebar of a static web page. For whatever reason, it is displaying the oldest post first while I want the newest post first in the list. Below is the code.
<?php $how_many=5; //How many posts do you want to show require_once("./news/wp-config.php"); // Change this for your path to wp-config.php file?> <ul> <? $news=$wpdb->get_results("SELECT 'ID','post_title' FROM $wpdb->posts WHERE 'post_status'= \"publish\" ORDER BY 'ID' ASC LIMIT ".$how_many); foreach($news as $np){ printf ("<li><a href=\"/news/index.php?p=%s\">%s</a></li>", $np->ID,$np->post_title); }?> </ul>
Any help would be much appreciated!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Most Recent Post Titles on Static Page’ is closed to new replies.