Adding Rss Feed Script to Homepage

Discussion in 'PHP' started by Christopher Thompson, Feb 25, 2009.

  1. #1
    I want to add script from my blog to my homepage so that on the front page viewers can see my recent blog entries. How do I do it?
     
    Christopher Thompson, Feb 25, 2009 IP
  2. Joak1m

    Joak1m Peon

    Messages:
    135
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Its quite easy with PHP SimpleXmlElement, heres an example

    
    <?php 
    $url = "http://feeds2.feedburner.com/2raccoon"; 
    $file = file_get_contents($url); 
    $xml = new SimpleXmlElement($file);
    foreach ($xml->channel->item as $entry){ 
    echo "<p><a href='$entry->link' title='$entry->title'>" . $entry->title . "</p>"; 
    }
    ?>
    
    PHP:
     
    Joak1m, Feb 25, 2009 IP
  3. unlimitedmoviez

    unlimitedmoviez Peon

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    r u using wordpress or something else
    if you are using wordpress then u can manage easily.you can use rss Widgets
     
    unlimitedmoviez, Feb 25, 2009 IP
  4. Christopher Thompson

    Christopher Thompson Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Script worked great, is it possible to limit number of posts that show. It shows 4 right now I only want two at a time?
     
    Christopher Thompson, Feb 25, 2009 IP
  5. infogle

    infogle Prominent Member

    Messages:
    2,732
    Likes Received:
    128
    Best Answers:
    1
    Trophy Points:
    300
    #5
    post numbers can be easily tweaked in your feedburner account...
     
    infogle, Feb 25, 2009 IP
  6. sundaybrew

    sundaybrew Numerati

    Messages:
    7,294
    Likes Received:
    1,260
    Best Answers:
    0
    Trophy Points:
    560
    #6
    You can use EXEC-PHP its a wordpress plugin that allows you to run PHP code in your posts I.E. feeds :)
     
    sundaybrew, Feb 25, 2009 IP
    Kerosene likes this.
  7. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #7
    $url = "http://feeds2.feedburner.com/2raccoon";
    
    $file = file_get_contents($url);
    $xml = new SimpleXmlElement($file);
    $total = 2;
    $counter = 0;
    foreach ($xml->channel->item as $entry) {
    	if(++$counter > $total) break;
        echo "<p><a href='$entry->link' title='$entry->title'>" . $entry->title . "</p>";
    }
    PHP:
     
    Danltn, Feb 25, 2009 IP
  8. JAZD Markets

    JAZD Markets Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I am also having trouble with limiting the number of links for my rss feed. I use the same code as above, but how do I get only 3 different articles to show at a time?
     
    JAZD Markets, Feb 27, 2009 IP