Excerpt of most recent post on static home page
-
I’ve managed to get the title of my most recent post on my home page but would also like an excerpt of the post.
I’ve searched the forums and found some solutions but nothing I’ve tried has worked.
Dealing with a bit of funky code I don’t understand so can’t figure out how to incorporate the solutions I’ve found into the code I’ve got.
Thanks for the help.
<?php $how_many=1; //How many posts do you want to show require_once('wp-config.php'); // Change this for your path to wp-config.php file ?> <? $news=$wpdb->get_results("SELECT <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 ("<li><a href=\"%s\">%s</a></li>", get_permalink($np->ID),$np->post_title); } ?>
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Excerpt of most recent post on static home page’ is closed to new replies.