


<?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>I am Lee Baillie &#187; PHP</title>
	<atom:link href="http://leebaillie.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://leebaillie.com</link>
	<description>And that&#039;s a stone-cold, hard fact.</description>
	<lastBuildDate>Thu, 29 Apr 2010 21:38:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Display Tweets on Your Wordpress Blog Without Plugins or Widgets</title>
		<link>http://leebaillie.com/display-tweets-on-your-wordpress-blog-without-plugins-or-widgets/</link>
		<comments>http://leebaillie.com/display-tweets-on-your-wordpress-blog-without-plugins-or-widgets/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 20:39:40 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Wordpress Hacks]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Twitter Hacks]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://leebaillie.com/?p=530</guid>
		<description><![CDATA[Yes, Twitter has an HTML widget that you can paste easily into any page. But the truth is that this widget is a little clunky and adds code to your page that can be a pain to style.
If you have a Wordpress blog, the whole process just got a little simpler with the wonderful hack [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, Twitter has an HTML widget that you can paste easily into any page. But the truth is that this widget is a little clunky and adds code to your page that can be a pain to style.</p>
<p>If you have a Wordpress blog, the whole process just got a little simpler with the wonderful hack displayed below. Simply replace *YOUR-TWITTER-USERNAME* with, you guessed it, your Twitter username and you&#8217;re done!</p>
<p>You can play around with it and add a prefix and a suffix where required. For example, you might wish to place a &#8216;follow me on Twitter&#8217; link at the end of your tweet.</p>
<p><del>A perfect example of its use can be seen at the top of this page. I&#8217;m using it myself.*</del> And you don&#8217;t need to worry about <a href="http://twitter.com/leebaillie" target="_blank">@somebody</a> links &mdash; they show up too.</p>
<p>Simply paste the PHP below where you want your tweets to appear and you&#8217;ll be up and running in no time. No clunky external JavaScripts or Wordpress widgets.</p>
<pre><code>
&lt;?php

$username = "*YOUR-TWITTER-USERNAME*";

// PREFIX - Place anything you want to appear BEFORE your tweet here
// WARNING: You can use HTML but remember to backslash any quotation marks (e.g. style=\"background:#FFF;\")
$prefix = "&lt;h3&gt;I tweet about...&lt;/h3&gt;";

// SUFFIX - Place anything you want to appear AFTER your tweet here
// WARNING: Same as for PREFIX
$suffix = "&lt;br /&gt; &lt;a href=\"http://twitter.com/*YOUR-TWITTER-USERNAME*\"&gt;follow me on Twitter&lt;/a&gt;";

$feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&amp;rpp=1";

function parse_feed($feed) {
    $stepOne = explode("&lt;content type=\"html\"&gt;", $feed);
    $stepTwo = explode("&lt;/content&gt;", $stepOne[1]);
    $tweet = $stepTwo[0];
    $tweet = str_replace("&amp;lt;", "&lt;", $tweet);
    $tweet = str_replace("&amp;gt;", "&gt;", $tweet);
    return $tweet;
}

$twitterFeed = file_get_contents($feed);
echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
?&gt;

</code></pre>
<p>Happy blogging/tweeting.</p>
<p>* I <em>was</em> using this piece of code but I&#8217;ve since re-designed my site. I needed slightly more functionality and this little snippet just didn&#8217;t quite cut it so I&#8217;ve had to revert back to Twitter&#8217;s own HTML widget.</p>
]]></content:encoded>
			<wfw:commentRss>http://leebaillie.com/display-tweets-on-your-wordpress-blog-without-plugins-or-widgets/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>
