Solved

Add RSS feed to Wordpress page

Posted on 2011-03-08
20
2,884 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
  • 11
  • 4
  • 2
  • +2
20 Comments
 
LVL 6

Accepted Solution

by:
music2myear1 earned 200 total points
Comment Utility
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
Comment Utility
Do you want it in the sidebar via a widget or some other way?
0
 
LVL 70

Expert Comment

by:Jason C. Levine
Comment Utility
Beat me to it, music2myear1!
0
 

Author Comment

by:COwebmaster
Comment Utility
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
Comment Utility
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
Comment Utility
ok, i'll try that.  so that will embed the actual content (not links) to the my page, yes?
0
 

Author Comment

by:COwebmaster
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I don't have control over the but my partner does
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

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

Expert Comment

by:jeremyjared74
Comment Utility
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
Comment Utility
ok, that would be great.
0
 
LVL 23

Assisted Solution

by:jeremyjared74
jeremyjared74 earned 200 total points
Comment Utility
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
Comment Utility
If you are adding it in the page editor, just switch to HTML view and add the code above.
0
 

Author Comment

by:COwebmaster
Comment Utility
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
Comment Utility
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
Comment Utility
ok, cool.  I try it...
0
 

Author Comment

by:COwebmaster
Comment Utility
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
Comment Utility
Thanks!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
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 purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now