Quantcast
Channel: Programming – Programming blog – website programming blog, blog on website programming .net, java , php and mor
Viewing all articles
Browse latest Browse all 31

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

$
0
0

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

$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;
}

?>


Viewing all articles
Browse latest Browse all 31

Trending Articles