Retrieve wordpress recent posts from external website

Discussion in 'Coding Help' started by GimmeDat, Jan 9, 2008.

  1. GimmeDat

    GimmeDat New Member

    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?
  2. mneylon

    mneylon Administrator 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 :)
  3. Forbairt

    Forbairt Portfolio Building

  4. GimmeDat

    GimmeDat New Member

  5. louie

    louie New Member

    if you own the blog you can just setup a db connection and pull the latest #? post from it.
  6. GimmeDat

    GimmeDat New Member

    Yes i own the blog. Would that involve much work?
  7. Forbairt

    Forbairt 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 ...
  8. GimmeDat

    GimmeDat New Member

    Thanks a mill. I'll give it a go.
  9. louie

    louie New Member

    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 : ');
    "<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, 
    $rs_blog mysql_query($sSql,$con) or die("no connection");
    $row_blog mysql_fetch_array($rs_blog)){
    "<li><a href='".$row_blog['guid']."' title='".
    htmlspecialchars(str_replace("'"," ",$row_blog['post_title']))."' target='_blank'>&bull; ".htmlspecialchars($row_blog['post_title'])."</a></li>"
  10. Forbairt

    Forbairt Portfolio Building

    Or give it a louie post .. so to speak :)

    might end up re-using myself .. save me half an hour of work :D cheers louie
  11. louie

    louie New Member

    no probs guys. just add the classes to your style sheet.
  12. dartagnanh

    dartagnanh New Member


    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?

Share This Page