View Single Post
  #11 (permalink)  
Old Jan 25th, 2008, 14:12
Emzi's Avatar
Emzi Emzi is offline
SuperMember

SuperMember
Join Date: Sep 2007
Location: Manchester
Age: 25
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Using wordpress posts in a static page

PHP: Select all

<?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 ?>

<?
$news
=$wpdb->get_results("SELECT `ID`,`post_title`,`post_content`, `post_date` FROM $wpdb->posts
WHERE `post_type`=\"post\" AND `post_status`= \"publish\" ORDER BY 'ID' DESC LIMIT "
.$how_many);
foreach(
$news as $np){
//echo ("$np->post_date<br />");
list ($y$m$d) = split('[/.-]'substr($np->post_date010));
 echo 
"Posted on: $d-$m-$y<br />";
print (
"<a href=\"");
echo 
get_permalink($np->ID);
print (
"\">$np->post_title</a><br />");
if (
strlen($np->post_content) > 65)
{
echo (
substr("$np->post_content"065)."... ");
}
else
{
echo (
"$np->post_content<br />");
}
print (
"<a href=\"");
echo 
get_permalink($np->ID);
print (
"\">&raquo; Read More</a><br /><br />");
?>
I did this for the website of the company I work for. I think that should work. Although this particular part is in an include so if it doesn't work you may need to fiddle with it a bit, although at the moment it looks fine
Reply With Quote