Mini-loop adding pages
-
Hi
I’ve set up a static page which uses a mini-loop to pull in recent posts into a sidebar.
Here’s the code:
<?php
$how_many=5;
require_once(“wordpress/wp-config.php”);
$news=$wpdb->get_results(“SELECT ID, post_title, post_excerpt FROM $wpdb->posts
WHERE post_status=’publish’ ORDER BY ID DESC LIMIT $how_many”);
foreach($news as $np){
echo ‘
<h2>ID).'”>’.$np->post_title.’</h2>
<p>’.$np->post_excerpt.'</p>’;
}
?>If I add a new page it also brings in the page by ID and puts a link in the middle of my recent posts list. Is there any way to stop it from doing this?
This is the first time I’ve used PHP so I’m really struggling.
Thanks
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Mini-loop adding pages’ is closed to new replies.