Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- # You will need to change these to reflect your actual wordpress database
- $dbhost = 'localhost' // This will probably be 'localhost' on your server
- $dbuser = 'username' // Your webhost will have given you this, and you will have used it in wordpress installation
- $dbpass = 'password' // Your webhost will have given you this, and you will have used it in wordpress installation
- $dbname = 'wordpress' // You will have decided this in wordpress installation
- $dbprefix = 'wp_' // You will have decided this in wordpress installation
- # Connect to the database system as a whole
- $con = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql (check your host, username and password)');
- # Using the connection from above, select the wordpress database
- $con = mysql_select_db($dbname) or die ('Could not select database (are you sure the name is right?)');
- # This query gets the 5 latest posts from the wordpress database
- $qry = mysql_query("SELECT * FROM ". $dbprefix ."posts ORDER BY post_date ASC LIMIT 5");
- # For each post from the query above...
- while($row = mysql_fetch_assoc($qry))
- {
- # ... do this:
- echo 'Post title: ' . $row['post_title'] . '<br />';
- echo 'Post excerpt: ' . $row['post_excerpt'] . '<br /><br />';
- }
- ?>
Add Comment
Please, Sign In to add comment