Title: Running PHP code..
Last modified: August 19, 2016

---

# Running PHP code..

 *  Resolved [piperis](https://wordpress.org/support/users/piperis/)
 * (@piperis)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/running-php-code/)
 * 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)

1 [2](https://wordpress.org/support/topic/running-php-code/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/running-php-code/page/2/?output_format=md)

 *  [jrm213](https://wordpress.org/support/users/jrm213/)
 * (@jrm213)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/running-php-code/#post-817749)
 * 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](https://wordpress.org/support/users/piperis/)
 * (@piperis)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/running-php-code/#post-817755)
 * 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.
 *  [jrm213](https://wordpress.org/support/users/jrm213/)
 * (@jrm213)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/running-php-code/#post-817757)
 * 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
       }
       ?>
       ```
   
 *  [jrm213](https://wordpress.org/support/users/jrm213/)
 * (@jrm213)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/running-php-code/#post-817760)
 * 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](https://wordpress.org/support/users/piperis/)
 * (@piperis)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/running-php-code/#post-817776)
 * thanks for ur reply….
    im trying to use this method: [http://www.tonyrocks.com/index.php/tutorials/adding-an-ebay-rss-feed-to-your-wordpress-blog/](http://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](https://wordpress.org/support/users/piperis/)
 * (@piperis)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/running-php-code/#post-817780)
 * the best i can do is get it to say rss file not found…!
 *  Thread Starter [piperis](https://wordpress.org/support/users/piperis/)
 * (@piperis)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/running-php-code/#post-817782)
 * 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 } ?>
 *  [jrm213](https://wordpress.org/support/users/jrm213/)
 * (@jrm213)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/running-php-code/#post-817785)
 * 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 [http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml](http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml)
   instead
 *  Thread Starter [piperis](https://wordpress.org/support/users/piperis/)
 * (@piperis)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/running-php-code/#post-817787)
 * changed it… nothing is being displayed, no errors or news… just blank page….
 *  [jrm213](https://wordpress.org/support/users/jrm213/)
 * (@jrm213)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/running-php-code/#post-817795)
 * 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](https://wordpress.org/support/users/piperis/)
 * (@piperis)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/running-php-code/#post-817802)
 * 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](https://wordpress.org/support/users/piperis/)
 * (@piperis)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/running-php-code/#post-817811)
 * finally, how can i add some text just above the rss stuff?
    whats the code??
 *  [jrm213](https://wordpress.org/support/users/jrm213/)
 * (@jrm213)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/running-php-code/#post-817815)
 * 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](https://wordpress.org/support/users/piperis/)
 * (@piperis)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/running-php-code/#post-817835)
 * Thanks again!
    All sorted!
 *  783720
 * [17 years, 8 months ago](https://wordpress.org/support/topic/running-php-code/#post-817933)
 * 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("http://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)

1 [2](https://wordpress.org/support/topic/running-php-code/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/running-php-code/page/2/?output_format=md)

The topic ‘Running PHP code..’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 17 replies
 * 4 participants
 * Last reply from: [adamiis111](https://wordpress.org/support/users/adamiis111/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/running-php-code/page/2/#post-818033)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
