I'm using the Mini Loop code to include a small prompt to my recent blog posts at the top of my static home page (http://www.dmk.com.au). This returns the 3 latest posts.
However, yesterday, I added a new *page* to my site, and now this is showing up in the "3 latest" mini loop of links (although if you click on it, it returns "Sorry, no posts matched your criteria" -- whereas when you click on one of the blog entries, it shows that post on a single page.
The code is:
<?php
# Here starts Mini Loop trick: You can use this code, but _at your own risk_
# If you want to improve this code, you're welcome ;)
$how_many=3; //How many posts do you want to show
?>
<ul class="front-post-title">
<?
$news=$wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts
WHERE post_status = \"publish\" ORDER BY ID DESC LIMIT " . $how_many);
foreach($news as $np){
printf ("<li><a href=\"index.php?p=%s\">%s</a></li>", $np->ID,$np->post_title);
}
?>
</ul>
I changed my headline above the link to say that this is a link to posts/pages -- until I can fix it, as I only want it to return results for posts, and not show pages.
I've looked through the Loop docs and support forum, but cannot find a suitable solution -- I guess that I need to tell it to ignore pages, but I don't know how to do that.
Please help! Thanks in advance... Dean