- 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_date, 0, 10));
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", 0, 65)."... ");
}
else
{
echo ("$np->post_content<br />");
}
print ("<a href=\"");
echo get_permalink($np->ID);
print ("\">» 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
