Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Display latest posts on other page


Ashfame
Participant

@ashfame

Use this in header :

<?php
// URL location of your feed
$feedUrl = "http://feeds2.feedburner.com/ashfameblog?format=xml";
// Replace the above URL with yours
$feedContent = "";

// Fetch feed from URL
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $feedUrl);
curl_setopt($curl, CURLOPT_TIMEOUT, 3);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);

// FeedBurner requires a proper USER-AGENT...
curl_setopt($curl, CURL_HTTP_VERSION_1_1, true);
curl_setopt($curl, CURLOPT_ENCODING, "gzip, deflate");
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3");

$feedContent = curl_exec($curl);
curl_close($curl);
?>

Use this to show :

<?php
$count=0;
// Did we get feed content?
if($feedContent && !empty($feedContent))
{
$feedXml = @simplexml_load_string($feedContent);
if($feedXml)
{
?>
<ul>
<?php foreach($feedXml->channel->item as $item): if($count==6) { break; } ?>
<li><a href="<?php echo $item->link; ?>"><?php echo $item->title; ?></a></li>
<?php $count++; endforeach; ?>
</ul>
<?php }} ?>

Skip to toolbar