I want to include a few latest post titles, date and author on the home (page)
-
I want to show the latest three (3) posts on the home page (a static) as teasers to the blog/news page. I have the code below, modified to look ok, but I can’t pull in the post_date and author above the title. Any help?
<?php $how_many=3; //How many posts do you want to show require_once('wp-config.php'); // Change this for your path to wp-config.php file ?> <h1>Latest News</h1> <?php $news=$wpdb->get_results("SELECT <code>post_date</code>, <code>ID</code>,<code>post_title</code> FROM $wpdb->posts WHERE <code>post_type</code>=\"post\" AND <code>post_status</code>=\"publish\" ORDER BY post_date DESC LIMIT $how_many"); foreach($news as $np){ printf ("<ul>",$np->post_date); printf ("<li class=\"latest-news\"><a href=\"index.php?p=%s\">%s</a></li>", $np->ID,$np->post_title, "</ul>"); }?>
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘I want to include a few latest post titles, date and author on the home (page)’ is closed to new replies.