This is an updated version without needing to enter extra excerpt. This uses the post itself and truncates it:
Code: Select all
function myTruncate($string, $limit, $break=".", $pad="...")
{
// return with no change if string is shorter than $limit
if(strlen($string) <= $limit) return $string;
// is $break present between $limit and the end of the string?
if(false !== ($breakpoint = strpos($string, $break, $limit))) {
if($breakpoint < strlen($string) - 1) {
$string = substr($string, 0, $breakpoint) . $pad;
}
}
return $string;
}
global $gCms;
global $db;
$vars = $gCms->variables;
$query2 = "SELECT date_format(post_date, '%Y/%m/%d') as date_format, post_title, post_excerpt, post_content, post_name FROM wp_posts WHERE post_type = 'POST' AND post_status ='publish' ORDER BY post_date DESC LIMIT 8";
$result2 = mysql_query($query2) or die("Error: " . mysql_error());
while($row = mysql_fetch_array( $result2 )) {
// Print out the contents of each row into a table
$date_format = $row["date_format"];
$post_title = $row["post_title"];
$post_name = $row["post_name"];
$post_excerpt = $row["post_excerpt"];
$post_content = $row["post_content"];
$postshort = myTruncate($post_content, 50);
echo "<a href='/blog/$date_format/$post_name/'>$post_title</a><br>";
echo "$postshort<br>";}
on the page where you want the title with short summary, just add:
This is the httacess if your blog is in the blog directory:
Code: Select all
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
This will result in url for the blog like:
blog/2008/01/05/lorem-ipsum-is-simply/
BTW-this is possible thanks to the following about php truncate!
http://www.the-art-of-web.com/php/truncate/