PHP code for Rss Feed

Code to get Title and Link in WordPress RSS Feed using PHP

You would often want to display the RSS feed of your blog in your personalized home page or your professional page. This can be achieved, if you have basic knowledge on PHP and HTML.

Just copy and paste the code below in the section where you want the feed to appear:

[php]
<?PHP

$con = file_get_contents(‘http://www.xxxxxx.com/blog/feed/’);/* Feed Url */
$title = getlinks("<title>", "</title>", $con); // gets Title and stored in array
$url = getlinks("<link>", "</link>", $con); // gets Url and stored in array

echo "<ul>";
for($i=0; $i < 6; $i++) {
echo ‘<li><a href="’.$url[$i].’" title="’.$title[$i].’" >’.urldecode($title[$i]).'</a></li>’;
}
echo "</ul>";

function getlinks($s1,$s2,$s) {
$myarray=array();
$s1 = strtolower($s1);
$s2 = strtolower($s2);
$L1 = strlen($s1);
$L2 = strlen($s2);
$scheck=strtolower($s);

do {
$pos1 = strpos($scheck,$s1);
if($pos1!==false) {
$pos2 = strpos(substr($scheck,$pos1+$L1),$s2);
if($pos2!==false) {
$myarray[]=substr($s,$pos1+$L1,$pos2);
$s=substr($s,$pos1+$L1+$pos2+$L2);
$scheck=strtolower($s);
}
}
}
while (($pos1!==false)and($pos2!==false));
return $myarray;
}

?>

[/php]

Tags:

Request a Free SEO Quote