• Resolved piperis

    (@piperis)


    I am trying to get a page to display an rss feed,
    i think i have found a php code that will do this,
    but i need help getting wordpress to run the code…

    i found a plugin but it doesnt support version 2.6
    can anyone help?

Viewing 15 replies - 1 through 15 (of 17 total)
  • It depends on where you want the rss feed to display.

    for example if you wanted it to display in the sidebar, you would open sidebar.php and place the code to display the feed in that file in the location you want it to appear. Can you give a little more detail?

    Thread Starter piperis

    (@piperis)

    i want to display the feed on a page…
    I have a page created, named News,
    and I want a news feed to appear under that page.

    Like i said i have tried several things but havent been able to get it working.

    ok, so we are talking about a page not a post.

    Edit page.php in your themes, theme directory ie(wp-content/themes/your-theme/page.php

    find where you want the rss feed to display, for example under your content.

    <div class="entry">
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    </div>

    under that make a new div for your rss feed

    <?php
    if(is_page('news'))
    {
    ?>
    <div class="rss">;
    <?php
    //paste your rss feed display php code here
    ?>
    </div>;
    <?php
    }
    ?>

    I Don’t know why it keeps putting ; next to the div and close div tags but those shouldn’t be there.

    Thread Starter piperis

    (@piperis)

    thanks for ur reply….
    im trying to use this method:
    https://www.tonyrocks.com/index.php/tutorials/adding-an-ebay-rss-feed-to-your-wordpress-blog/

    but i cant get it to work, the lastrss file isnt helping.

    I just need a nice clean bit of code that will parse the rss

    Thread Starter piperis

    (@piperis)

    the best i can do is get it to say rss file not found…!

    Thread Starter piperis

    (@piperis)

    this is my code atm:

    <?php
    if(is_page(‘News’))
    {
    ?>
    <div class=”rss”>
    <?php
    // include lastRSS library
    include ‘./lastRSS.php’;

    // create lastRSS object
    $rss = new lastRSS;

    // setup transparent cache
    $rss->cache_dir = ‘./cache’;
    $rss->cache_time = 3600; // one hour

    // load some RSS file
    if ($rs = $rss->get(‘feed://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml&#8217;)) {
    // here we can work with RSS fields
    }
    else {
    die (‘Error: RSS file not found…’);
    }
    ?>
    </div>
    <?php
    }
    ?>

    ok, well I am not positive on this, but feed:// really isn’t valid. Some browsers may interpret or replace it for you if you paste that in the url.

    try https://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml instead

    Thread Starter piperis

    (@piperis)

    changed it… nothing is being displayed, no errors or news… just blank page….

    ok, so now you have a variable called $rs which is an object that contains the result of the function call $rss->get . That object must have functions and variables associated with it to display the feed, check the provider of lastrss and see how they tell you to display your feed data. example:
    replace
    // here we can work with RSS fields

    with the following from one of t

    echo "<ul>\n";
        foreach($rs['items'] as $item) {
            echo "\t<li><a href=\"$item[link]\">".$item['title']."</a><br />".$item['description']."</li>\n";
            }
        echo "</ul>\n";

    change the above as needed to display your output styled the way you want it. Also, check out documentation on lastrss they have some good examples with sourcecode

    Thread Starter piperis

    (@piperis)

    just gave it a go, and it worked!!
    thanks sooo much, i have posted a few times to get this sorted and finally have sorted it, thanks to you!

    Top (wo)man!!!! lol
    Thanks again…

    Thread Starter piperis

    (@piperis)

    finally, how can i add some text just above the rss stuff?
    whats the code??

    You want some other text only on the News Page, but above the RSS Feed stuff?

    directly above:
    <div class="rss">

    put your content.

    example:

    <?php
    if(is_page('news'))
    {
    ?>
    <div>
    //put your text you want above the feed here
    </div>
    <div class="rss">
    <?php
    //paste your rss feed display php code here
    ?>
    </div>
    <?php
    }
    ?>
    Thread Starter piperis

    (@piperis)

    Thanks again!
    All sorted!

    So I’m having a similar problem… except I’m trying to retrieve my WordPress feed to display on my website. The feed is valid, but no matter what feed type I use (rss, rss2, atom, rdf), lastRSS won’t retrieve it.

    This is how I call it:

    <?php include "./public/lastrss.php"; // include lastRSS
      $rss = new lastRSS; // Create lastRSS object
      $rss->cache_dir = './public/cache';
      $rss->cache_time = 43200;
      // Try to load and parse RSS file
      if ($rs = $rss->get("https://blog.worderella.com/index.php?feed=rss2")) {
        // Show last published articles (title, link, description)
        echo "<ul>\n";
        foreach($rs['items'] as $item) {
          echo "\t<li><a href=\"$item[link]\">".$item['title']."</a>".$item['pubDate']."</li>\n";
        }
        echo "</ul>\n";
      }
      else { echo "Items not found."; }
    ?>

    It returns “Items not found.” on my website. Any suggestions?

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Running PHP code..’ is closed to new replies.