Part 5: How To Display Wordpress posts on your PHP site.
Posted by | Posted in Development, School, Tutorial, Uncategorized | Posted on 17-10-2008
Welcome to the Final Part 5: How To Display Wordpress posts on your PHP site
This is the last part of the tutorial. Here you can see the Final codes. and you can use the See the final result on my demo test page.
The final Codes:
I will now post the final codes of the index.php and the wpconf.php file. You may use the Codes in it but please link back to my blog if you use it. I would like that. Well here are the codes and i hope i helped you a bit with it.
Index.php:
<html>
<head>
<title>Test Page Title</title>
<?php require("wpconf.php"); ?>
</head>
<body>
<?php
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) { ?>
<a href="<?php echo $row['guid']; ?>"><?php echo $row['post_title']; ?></a><br><br>
Post Date: <?php echo $row['post_date_gmt']; ?>
<hr>
<?php
}
?>
</body>
</html>
wpconf.php
<?php
// Make a MySQL Connection
mysql_connect("localhost", "DatabaseUser", "DatabasePassword") or die(mysql_error());
mysql_select_db("DatabaseName") or die(mysql_error());
// Get all the data from the "wp_posts" table
$result = mysql_query("SELECT * FROM wp_posts WHERE post_type='post' ORDER BY ID DESC LIMIT 15")
or die(mysql_error());
?>
Thank you for reading my tutorial and i hope you are happy with it. Take care and keep coding ;) Also keep designing for those who do that.
The end of Part 5, And the end of the Tutorial.



