• Resolved davve00

    (@davve00)


    How do I show latest 5 posts on my non-wp site? I want to show the posts on my index site?

    What page do i need to include on my index, and what code do i need to use for getting the posts from the db? (or is there a way of getting the posts in another way?)

    davve

Viewing 3 replies - 1 through 3 (of 3 total)
  • google magpieRSS… parse your wordpress RSS feed.

    Thread Starter davve00

    (@davve00)

    hmm, seems a bit unnecessary, or am I wrong about how to use magpie? I place magpie in a folder on my server, then apply a script like this:

    <?php
    define('MAGPIE_DIR', '/magpie/');
    require_once(MAGPIE_DIR.'rss_fetch.inc');
    
    $rss = fetch_rss( 'https://www.yoursite.com/yourfolder/atom.xml' );
    
    //display latest blog content:
    $item = $rss->items[0];
    $content = $item['atom_content'];
    echo "<p>Latest Blog Entry:$content</p>\n";
    ?>

    But I dont have the atom.xml file? I guess i must edit WP to generate the atom.xml?

    im sorry if im a bit unclear.. it is on the same server, but not in the wordpress it self… I want to show recent posts on my index page and I have the wordpress in folder /word/ on the same server…

    davve

    Thread Starter davve00

    (@davve00)

    ah, I got it to work with:

    <?php include('magpie/rss_fetch.inc');
    
    error_reporting(E_ERROR);
    
    $rss = fetch_rss('word/?feed=rss2');
    if ($rss) {
     $items = array_slice($rss->items, 0, 5);
     foreach ($items as $item )
     {   echo '<li><a href="'.$item['link'].'"><span class="date">'.$item['title'].'</a> - '.$item['author'].'</li>';  }
    }
    else
    {
      echo '<h2>Error:</h2><p>'.magpie_error().'</p>';
    }
    // Restore original error reporting value
    @ini_restore('error_reporting');
    ?>

    Thanks! Anyone have trouble using magpie try https://www.olate.co.uk/articles/view.php?id=214

    davve

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do i show recent posts on non-wp site?’ is closed to new replies.