Mike Waller
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you want it in the sidebar via a widget or some other way?
Beat me to it, music2myear1!
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok, i'll try that. so that will embed the actual content (not links) to the my page, yes?
ASKER
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?
ASKER
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I don't have control over the but my partner does
ASKER
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.
I will let you know if I find a way.
ASKER
ok, that would be great.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you are adding it in the page editor, just switch to HTML view and add the code above.
ASKER
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)?
Also, if I wanted to display more than just the five links, say unlimited, what would I add (or remove)?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok, cool. I try it...
ASKER
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>
<?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>
ASKER
Thanks!