<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Themocracy WordPress Themes &#187; simplepie</title>
	<atom:link href="http://themocracy.com/tag/simplepie/feed/" rel="self" type="application/rss+xml" />
	<link>http://themocracy.com</link>
	<description>WordPress Theme Design</description>
	<lastBuildDate>Mon, 26 Jul 2010 06:18:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>WordPress RSS Functions</title>
		<link>http://themocracy.com/2009/07/wordpress-rss-functions/</link>
		<comments>http://themocracy.com/2009/07/wordpress-rss-functions/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 12:40:48 +0000</pubDate>
		<dc:creator>Lisa</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[simplepie]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://themocracy.com/?p=119</guid>
		<description><![CDATA[So you want to get a RSS feed and echo it to a WordPress page or sidebar &#8211; you&#8217;ve already got the RSS sidebar widget feature, but what if you want a little more control over what&#8217;s coming out? New in WordPress 2.8 is the fetch_feed() function &#8211; as the name suggests, a means of [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fthemocracy.com%2F2009%2F07%2Fwordpress-rss-functions%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fthemocracy.com%2F2009%2F07%2Fwordpress-rss-functions%2F" height="61" width="51" /></a></div><p><img src="http://themocracy.com/wp-content/uploads/2009/07/rss_img.jpg" alt="rss_img" title="rss_img" width="130" height="136" class="alignright size-full wp-image-126" /><strong>So you want to get a RSS feed and echo it to a WordPress page or sidebar</strong> &#8211; <em>you&#8217;ve already got the RSS sidebar widget feature, but what if you want a little more control over what&#8217;s coming out?</em></p>
<p>New in WordPress 2.8 is the <strong>fetch_feed()</strong> function &#8211; as the name suggests, a means of retrieving an external RSS feed, parsing it (extracting the relevant info, for output purposes) and also caching the raw data to ease the strain on both servers.<br />
<span id="more-119"></span><br />
fetch_feed() uses the Simplepie class to fetch and manipulate the RSS &#8211; in constrast to the functions it replaces, wp_rss(), get_rss() etc., which stuck with good old Magpie and Snoopy to get the job done.</p>
<p>And the use of the function itself is simplicity:</p>
<pre class="brush: php">
if(function_exists(&#039;fetch_feed&#039;)){
$uri = &#039;http://themocracy.com/feed/&#039;;
$feed = fetch_feed($uri);
}
</pre>
<p>Notice the function_exists check, to ensure compatibility&#8230;</p>
<p>The simplepie object returned is complex (some might say a touch clumsy, but probably necessarily so in order to handle the wide variety of XML lumped together under the heading RSS). <em>Don&#8217;t try to work with it directly&#8230; </em></p>
<p>Instead, what Simplepie has is methods to get at the data:<br />
This code retrieves the overall feed title and then loops through the RSS items, grabbing and outputting the relevant item data.</p>
<pre class="brush: php">
printf( $feed-&gt;get_title());

foreach ($feed-&gt;get_items() as $item){

printf(&#039;&lt;p&gt;&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;&lt;/p&gt;&#039;,$item-&gt;get_permalink(), $item-&gt;get_title());
printf(&#039;&lt;p&gt;%s&lt;/p&gt;&#039;,$item-&gt;get_description());
printf(&#039;&lt;p&gt;&lt;small&gt;%s&lt;/small&gt;&lt;/p&gt;&#039;,$item-&gt;get_date(&#039;j F Y | g:i a&#039;));
}
</pre>
<p>That&#8217;s the basic idea &#8211; see the <a href="http://simplepie.org/wiki/">Simplepie docs</a> for more&#8230;</p>
<p>You might want to try it as a quick way of getting a Twitter feed onto a page &#8211; or any other ideas for using RSS  feeds directly&#8230;?</p>
]]></content:encoded>
			<wfw:commentRss>http://themocracy.com/2009/07/wordpress-rss-functions/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

