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
Thanks! You have no idea how grateful I am for your help. It worked!!!
You wouldn't also happen to know I can add a permalink to the bottom of a post excerpt that says something like 'Read More...". I know the post_title does this but I also want to add a "Read more" link at the bottom of the excerpt.
Thanks so much!
"more" and the_excerpt are TWO (2) different techniques to... shorten(?), cut your content.
"more" is added manually where you want the break, while writing the post - the_excerpt works on its own.
You can customize the "more" just by editing your template files:
http://codex.wordpress.org/Customizing_the_Read_More
For a "custom" excerpt, you need a plugin:
http://guff.szub.net/2005/02/26/the-excerpt-reloaded/
Thanks! I've had a quick look and it looks like it will do what I need.
Thanks so much for your help, I really appreciate it.