หาเจอแล้วครับ...ตามนี้เลยครับ
Here is the script:
<?php
//MySQL Username
$user = "wordpress-blog-database- username-goes here";
//MySQL Password
$pass = "wordpress-blog-database-password-goes-here";
//MySQL Database Name
$database = "wordpress-blog-database-name-goes-here";
//Number of posts you want to have appear
$numOfPosts = 7;
//Setup connection
$mysqli = new mysqli("localhost", $user, $pass, $database);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$limit = $numOfPosts;
$sql = "SELECT * FROM wp_posts WHERE post_type = 'post' AND post_status IN ( 'draft', 'publish', 'future', 'pending', 'private' ) ORDER BY post_date DESC LIMIT $limit";
$result = $mysqli->query($sql);
while ($row = $result->fetch_object()) {
echo '<ul>';
echo '<li><a href="'.$row->guid.'">'.$row->post_title.'</a></li>';
echo '</ul>';
}
?>
Once you have editted the script with your Wordpress Database details, and set the number of recent posts you want passed over, simply use a php include to where you want the results to be. Here is an example:
<?php include($_SERVER['DOCUMENT_ROOT'] .'/whatever-you-decide-to-call-this.php'); ?>
And there you go!
Enjoy,
