Solved

Add RSS feed to Wordpress page

Posted on 2011-03-08
20
3,097 Views
Last Modified: 2013-11-18
I'm trying to add a rss feed to my wordpress page.  Does anyone know of a good one?  I have the url to the feed but just need to now embed it into the page.
0
Comment
Question by:COwebmaster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 4
  • 2
  • +2
20 Comments
 
LVL 6

Accepted Solution

by:
music2myear1 earned 200 total points
ID: 35075005
Just a scrolling feed in a side bar or as conten on a static page?

If you're looking for a sidebar feed, wordpress has a built in RSS widget that'll do that just fine.

If you are looking for it to show on a statis page, search the Wordpress plugin repository for "RSS Page". The results are all rated and show the number of users.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35075017
Do you want it in the sidebar via a widget or some other way?
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35075028
Beat me to it, music2myear1!
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:COwebmaster
ID: 35075046
I need it embedded on a page, not in the sidebar.  I see a widget for it but I need the feed to display on the actual page (not post).
0
 
LVL 23

Assisted Solution

by:jeremyjared74
jeremyjared74 earned 200 total points
ID: 35075120
You can do it through a short-code. You just need to add this to your functions.php file and then you can call it with a short-code in the page you want.


functions.php code:
 
<?php
    include_once(ABSPATH.WPINC.'/rss.php');
    function readRss($atts) {
        extract(shortcode_atts(array(
    	"feed" => 'http://',
          "num" => '1',
        ), $atts));
          ob_start();
        wp_rss($feed, $num);
        return ob_get_clean();
    }
    add_shortcode('rss', 'readRss'); ?>

Open in new window


Then to call it in the page editor:
[rss feed="http://feed url here" num="5"]

Open in new window

NOTE: You need to add your URL where the http:// is in the code.
0
 

Author Comment

by:COwebmaster
ID: 35075174
ok, i'll try that.  so that will embed the actual content (not links) to the my page, yes?
0
 

Author Comment

by:COwebmaster
ID: 35075264
that worked but it didn't embed the stories onto my webpage.  it just has links to the stories on the site where it displays the stories.  Is that how the rss on a page is supposed to be?
0
 

Author Comment

by:COwebmaster
ID: 35075405
I embedded that info the functions.php page.  Is there a way now to make it so that the links on that page open to a new window.  how would I add in target="_blank"> ?
0
 
LVL 6

Assisted Solution

by:music2myear1
music2myear1 earned 200 total points
ID: 35077408
The issue is probably that the feed you're trying to pull only publishes links. Are you providing the source of the feed? If so you need to set the publishing settings to publish the entire article and not just links.

The problem occurs when you don't have control of the feed.

Pardon my being harsh, but if you're not in control of the feed there's legitimate reason to ask why you're trying to create full posts from an RSS feed. If you're just creating one of the bottom-feeding scumbag sites that google rightfully crucified last week, I'll happily leave you hanging. I've encountered that type asking similar questions here before.

But if not, by all means, check the source of the feed. If the feed only publishes links, you're only going to get links.
0
 

Author Comment

by:COwebmaster
ID: 35077463
I don't have control over the but my partner does
0
 

Author Comment

by:COwebmaster
ID: 35077885
how would I make it so that the links open up in a new window?
0
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 35078030
The best solution to opening in a new window I've been able to find is by using javascript. Certainly there is a way to add to the functions without js?

I will let you know if I find a way.
0
 

Author Comment

by:COwebmaster
ID: 35078058
ok, that would be great.
0
 
LVL 23

Assisted Solution

by:jeremyjared74
jeremyjared74 earned 200 total points
ID: 35078107
I seem to have read your question wrong. You only need a link embedded into your page for  an RSS feed which you already have>


Just add the link:
<a href="http://yourwebsite.com/rss" target="_blank">My RSS FEED</a> 

Open in new window


If you want it on all pages, add it to the loop of either or all of these files:
index.php, page.php, single.php, category.php, archives.php
0
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 35078113
If you are adding it in the page editor, just switch to HTML view and add the code above.
0
 

Author Comment

by:COwebmaster
ID: 35078227
no, you had it right before.  I can display the links from the feed on my page.  However, the owner of each feed wants each link to open in a new window.  how do I take this [rss feed="http://feed url here" num="5"] which displays the 5 links to open each link into a new window?

Also, if I wanted to display more than just the five links, say unlimited, what would I add (or remove)?
0
 
LVL 31

Assisted Solution

by:gwkg
gwkg earned 100 total points
ID: 35096281
wp_rss() has been depreciated.  You should use fetch_feed()

http://codex.wordpress.org/Function_Reference/fetch_feed

You can use their sample code and add target='_blank' to the <a> tag in this loop

    // Loop through each feed item and display each item as a hyperlink.
    foreach ( $rss_items as $item ) : ?>
    <li>
        <a href='<?php echo $item->get_permalink(); ?>' target='_blank'
        title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'>
        <?php echo $item->get_title(); ?></a>
    </li>
    <?php endforeach; ?>
0
 

Author Comment

by:COwebmaster
ID: 35100016
ok, cool.  I try it...
0
 

Author Comment

by:COwebmaster
ID: 35102429
so do I need to download feed.php from simplepie to make this script work?  From that site I have:

<?php

// Get RSS Feed(s)

include_once(ABSPATH . WPINC . '/feed.php');

// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed('http://domain.com/rss');
if (!is_wp_error( $rss ) ) : // Checks that the object is created correctly
    // Figure out how many total items there are, but limit it to 5.
    $maxitems = $rss->get_item_quantity(5);

    // Build an array of all the items, starting with element 0 (first element).
    $rss_items = $rss->get_items(0, $maxitems);
endif;
?>

<ul>
    <?php if ($maxitems == 0) echo '<li>No items.</li>';
    else
    // Loop through each feed item and display each item as a hyperlink.
    foreach ( $rss_items as $item ) : ?>
    <li>
        <a href='<?php echo $item->get_permalink(); ?>'
        title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'>
        <?php echo $item->get_title(); ?></a>
    </li>
    <?php endforeach; ?>
</ul>

0
 

Author Closing Comment

by:COwebmaster
ID: 35838631
Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question