You could use something along these lines:
<?php
// Call the database connection settings
require( path-to- /wp-config.php );
// Connect to WP database
$dbc = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if ( !$dbc ) {
die( 'Not Connected: ' . mysql_error());
}
// Select the database
$db = mysql_select_db(DB_NAME);
if (!$db) {
echo "There is no database: " . $db;
}
// Formulate the query
$query = "
SELECT post_title,post_content,UNIX_TIMESTAMP(post_date) AS post_date_unix
FROM `wp_posts`
WHERE `post_status` = 'publish'
AND `post_password` = ' '
AND `post_type` = 'post'
ORDER BY `wp_posts`.`post_date` DESC
";
// Perform the query
$result = mysql_query( $query );
// Check results of the query and terminate the script if invalid results
if ( !$result ) {
$message = 'Invalid query.' . PHP_EOL;
$message .= 'Whole query: ' . $query . PHP_EOL;
die ( $message );
}
/*
* QUERY RESULT VARIABLES
*/
// Count the number of rows returned by the query
$num_rows = mysql_num_rows( $result );
// Use the results of query
$row = mysql_fetch_array( $result, MYSQL_ASSOC );
// Init var for DATE of the post
$post_date = date( "l, F jS, Y ", $row['post_date_unix'] );
// Init var for TITLE of the post
$post_title = $row['post_title'];
// Init var for CONTENT of the post
$post_content = $row['post_content'];
// Free the resources associated with the result set
if ( $result ) {
mysql_free_result( $result );
mysql_close();
?>
You now have variables for the most recent post:
Post Title: $post_title
Post Date: $post_date
Post Content: $post_content
as well as the total number of posts:
Number of posts: $num_rows
Example use:
The total number of posts is <?php echo $num_rows; ?>.
The most recent post:
<h2><?php echo $post_title; ?></h2>
<p class="post-meta">Posted: <?php echo $post_date; ?>
<?php echo $post_content; ?>
Again, this is just a quick look over. You can use this script instead of the one I supplied earlier as this one provides you with all the variable needed.