How Can I Show Feeds In Wordpress?

Discussion in 'XML & RSS' started by wragge11, Apr 1, 2008.

  1. #1
    So, I moving my site from PHP script to wordpress, and I have quite a few feeds that display news for me, along with the Premier League Table. So I was wondering, how can I show these pages in Wordpress?

    I have tried just pasting the information in, but to no avail. This is an example of one of the feeds, that then outputted onto another page.

    <?php
    $insideitem = false;
    $tag = '';
    $title = '';
    $description = '';
    $link = '';
    
    function startElement($parser, $name, $attrs) {
     global $insideitem, $tag, $title, $description, $link;
     if ($insideitem) {
      $tag = $name;
     } elseif ($name == 'ITEM') {
      $insideitem = true;
     }
    }
    
    function endElement($parser, $name) {
     global $insideitem, $tag, $title, $description, $link;
     if ($name == 'ITEM') {
      printf('<p><b><a href=\'%s\'>%s</a></b><br>',
       trim($link),trim($title));
      printf('%s</p>'."\n",trim($description));
      $title = '';
      $description = '';
      $link = '';
      $insideitem = false;
     }
    }
    
    function characterData($parser, $data) {
     global $insideitem, $tag, $title, $description, $link;
     if ($insideitem) {
     switch ($tag) {
      case 'TITLE':
      $title .= $data;
      break;
      case 'DESCRIPTION':
      $description .= $data;
      break;
      case 'LINK':
      $link .= $data;
      break;
     }
     }
    }
    
    $xml_parser = xml_parser_create();
    xml_set_element_handler($xml_parser, 'startElement', 'endElement');
    xml_set_character_data_handler($xml_parser, "characterData");
    $fp = fopen('http://newsapi.bbc.co.uk/feeds/search/news+sport/everton','r')
     or die('Error reading RSS data.');
    while ($data = fread($fp, 4096)) {
     xml_parse($xml_parser, $data, feof($fp))
      or die(sprintf('XML error: %s at line %d',
     xml_error_string(xml_get_error_code($xml_parser)),
     xml_get_current_line_number($xml_parser)));
    }
    fclose($fp);
    xml_parser_free($xml_parser);
    ?>
    
    PHP:
    Thanks :D
     
    wragge11, Apr 1, 2008 IP
  2. allout

    allout Prominent Member

    Messages:
    5,000
    Likes Received:
    461
    Best Answers:
    2
    Trophy Points:
    340
    #2
    If your theme is widget ready, you can put it in the sidebar with widgets by choosing RSS. If not, you can find a plug in to do it.
     
    allout, Apr 1, 2008 IP
  3. wragge11

    wragge11 Guest

    Messages:
    2,222
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It is widget ready...
    Although, I really only want the table in the sidebar, the rest on pages in WP.

    Any ideas?
     
    wragge11, Apr 1, 2008 IP
  4. allout

    allout Prominent Member

    Messages:
    5,000
    Likes Received:
    461
    Best Answers:
    2
    Trophy Points:
    340
    #4
    I know there is a plugin to do that but I am not sure what it is called now. Goto wordpress.org and search the plug ins for RSS feed and i am sure you will find it.
     
    allout, Apr 1, 2008 IP
  5. wragge11

    wragge11 Guest

    Messages:
    2,222
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Anyone else?
     
    wragge11, Apr 1, 2008 IP