Forum Moderators: coopster
/* Version check */
global $wp_version;
$exit_msg='WP-Append-RSS requires WordPress 2.3 or newer.
<a href="http://codex.wordpress.org/Upgrading_WordPress">Please
update!</a>';
if (version_compare($wp_version,"2.3","<"))
{
exit ($exit_msg);
}
require_once(ABSPATH . WPINC . '/feed.php');
require_once(ABSPATH . WPINC . '/post.php');
global $post;
function WP_Get_The_Feed () {
$rss = fetch_feed('http://www.t2fr.com/feed');
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;
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 ) :
$theurl = $item->get_permalink();
$thetitle = $item->get_title();
$thefeedstuff = "<li><a href= $theurl>$thetitle</a></li>";
echo $thefeedstuff;
//end the loop.
endforeach;
}
//function specifically for adding the links to the end of the post.
function WP_Append_The_Links($content)
{
return $content.Wp_Get_The_Feed();
}
add_filter('the_content', 'WP_Append_The_Links');
?>
<?php
function nothing(){
echo 'nasty';
}
echo 'Hello '.nothing().' world';
?>
<?php
/* Version check */
global $wp_version;
$exit_msg='WP-Append-RSS requires WordPress 2.3 or newer.
<a href="http://codex.wordpress.org/Upgrading_WordPress">Please
update!</a>';
if (version_compare($wp_version,"2.3","<")) {
exit ($exit_msg);
}
require_once(ABSPATH . WPINC . '/feed.php');
require_once(ABSPATH . WPINC . '/post.php');
global $post;
function WP_Get_The_Feed() {
$str = '<li>No items.</li>';
$rss = fetch_feed('http://www.t2fr.com/feed');
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);
if ($maxitems) {
$str = '';
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
// Loop through each feed item and display each item as a hyperlink.
foreach ($rss_items as $item) :
$theurl = $item->get_permalink();
$thetitle = $item->get_title();
$str .= '<li><a href="'.$theurl.'">'.$thetitle.'</a></li>';
}
}
}
return $str;
}
//function specifically for adding the links to the end of the post.
function WP_Append_The_Links($content) {
return $content.Wp_Get_The_Feed();
}
add_filter('the_content', 'WP_Append_The_Links');
?>