Link to home
Start Free TrialLog in
Avatar of Mike Waller
Mike WallerFlag for United States of America

asked on

Add RSS feed to Wordpress page

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.
ASKER CERTIFIED SOLUTION
Avatar of music2myear1
music2myear1
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jason C. Levine
Do you want it in the sidebar via a widget or some other way?
Beat me to it, music2myear1!
Avatar of Mike Waller

ASKER

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).
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok, i'll try that.  so that will embed the actual content (not links) to the my page, yes?
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?
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"> ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I don't have control over the but my partner does
how would I make it so that the links open up in a new window?
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.
ok, that would be great.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you are adding it in the page editor, just switch to HTML view and add the code above.
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)?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok, cool.  I try it...
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>

Thanks!