Retrieve wordpress recent posts from external website

Not open for further replies.
Hello All, just looking for recommendations on which is the best way to parse the recent posts of a wordpress blog onto another non blog website?


Staff member
Simplest solution would be to use RSS.

There's plenty of ways of doing it. If you're lazy you could use feedburner, like I'm doing on Michele J. Neylon :: Web ramblings and more..

OR you could use one of the many RSS libraries like Carp etc., etc.

Up to you really :)

Of course if you were using MovableType you could simply use a widget :)


Portfolio Building
if you just want to pull the posts ... and so on ...

about 15 minutes to half an hour

to actually write the bit of code probably a minute ... to format it nicely and so on ... probably the rest of the time ...
there is something I use myself
$show_blog = true;
//replace HOST, USER, PASS, DB_NAME with your DB details
$limit = 10;
 $con = mysql_connect(HOST,USER,PASS);
 if (!$con){ die('Could not connect: '); }
 // make foo the current db
 $db_selected = mysql_select_db('DB_NAME', $con);
 if (!$db_selected) {
  die ('Can\'t use db : ');
 echo "<div class='left_tab'>Recent Posts...</div>
  <div class='left_menu'>
 $sSql = "SELECT `ID`,`post_title`, `wp_posts`.`guid` FROM `wp_posts` WHERE `wp_posts`.`post_status` =  'publish' 
 AND `wp_posts`.`post_type` =  'post' ORDER BY `wp_posts`.`post_date` DESC LIMIT 0, $limit"; 
 $rs_blog = mysql_query($sSql,$con) or die("no connection");
 while($row_blog = mysql_fetch_array($rs_blog)){
  echo "<li><a href='".$row_blog['guid']."' title='".
  htmlspecialchars(str_replace("'"," ",$row_blog['post_title']))."' target='_blank'>&bull; ".htmlspecialchars($row_blog['post_title'])."</a></li>"; 
 echo "</ul>

Thanks a lot for the code snippet. I know a bit of PHP. Question: Will my db password be safe from prying eyes if I input it in this piece of code?
Not open for further replies.
Award-winning Mac antivirus and Internet security software