March 8th, 2009, 06:19 AM
Need to display the latest wordpress post on another site.
I am creating a new site with php ( not based on wordpress ) and i am also wordpress in it for blogging, i've installed the wordpress in the /blog directory.. I want to display the latest post of wordpress with a short description of it in my front page of the website in the /root directory...
I want a help fro creating this script.. i dont have much idea of scriting so can any one help me out to make this script...
March 12th, 2009, 10:43 PM
directory is (largely) irrelevant - as long as you know the access details (host, name, user, password) for the wordpress database, you can simply read the latest post(s) in your main site:
Originally Posted by artinsane
$db_username = "";
$db_password = "";
$db_database = "";
$db_hostname = "";
//connect to the database
mysql_connect($db_hostname, $db_username, $db_password);
@mysql_select_db($db_database) or die("Unable to select database");
$query = "Select * FROM wp_posts WHERE post_type='post' AND post_status='publish' AND post_category='News Flash' ORDER BY id DESC LIMIT 1";
$query_result = mysql_query($query);
$num_rows = mysql_numrows($query_result);
$blog_title = mysql_result($query_result, $i, "post_title");
$blog_content = mysql_result($query_result, $i, "post_content");
$blog_permalink = mysql_result($query_result, $i, "guid");
$blog_date = mysql_result($query_result, $i, "post_date");