Showing Twitter post in WP blog works, but the links don't
Posted: Mon Nov 30, 2009 9:28 am
Hello,
I hope there's a helpful PHP expert who can help me with the following:
I've successfully pulled my latest twitter post into my WP page, but the links doesn't work. Instead of the link address alone, it's linking to [my domain]+[link]
See for yourself at http://jlangvad.com (at the bottom of the page)
The code I've added is:
----------------
<div class="blockBotDiv2">
<div class="grayTitle">LATEST TWEET</div>
<div class="smallBotText">
<?php
$username = "jlangvad"; // Your twitter username.
$prefix = ""; // Prefix - some text you want displayed before your latest tweet.
$suffix = " Read all entries at "; // Suffix - some text you want display after your latest tweet.
$feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";
function parse_feed($feed) {
$stepOne = explode("<content type=\"html\">", $feed);
$stepTwo = explode("</content>", $stepOne[1]);
$tweet = $stepTwo[0];
$tweet = str_replace("<", "<", $tweet);
$tweet = str_replace(">", ">", $tweet);
return $tweet;
}
$twitterFeed = file_get_contents($feed);
echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
?>
<a href="http://twitter.com/jlangvad" target="_blank">twitter.com/jlangvad</a>
</div>
---------------
How can I change this?
Best,
Jacob Langvad
I hope there's a helpful PHP expert who can help me with the following:
I've successfully pulled my latest twitter post into my WP page, but the links doesn't work. Instead of the link address alone, it's linking to [my domain]+[link]
See for yourself at http://jlangvad.com (at the bottom of the page)
The code I've added is:
----------------
<div class="blockBotDiv2">
<div class="grayTitle">LATEST TWEET</div>
<div class="smallBotText">
<?php
$username = "jlangvad"; // Your twitter username.
$prefix = ""; // Prefix - some text you want displayed before your latest tweet.
$suffix = " Read all entries at "; // Suffix - some text you want display after your latest tweet.
$feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";
function parse_feed($feed) {
$stepOne = explode("<content type=\"html\">", $feed);
$stepTwo = explode("</content>", $stepOne[1]);
$tweet = $stepTwo[0];
$tweet = str_replace("<", "<", $tweet);
$tweet = str_replace(">", ">", $tweet);
return $tweet;
}
$twitterFeed = file_get_contents($feed);
echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
?>
<a href="http://twitter.com/jlangvad" target="_blank">twitter.com/jlangvad</a>
</div>
---------------
How can I change this?
Best,
Jacob Langvad