Skip to content

Instantly share code, notes, and snippets.

@dcatkins40
Created January 25, 2013 16:49
Show Gist options
  • Select an option

  • Save dcatkins40/4635964 to your computer and use it in GitHub Desktop.

Select an option

Save dcatkins40/4635964 to your computer and use it in GitHub Desktop.
A PHP RSS Reader that will sort through a RSS feed to only display posts tagged with a specific category.
<?php
$url = "$URL_of_feed";
$rss = simplexml_load_file($url);
$items = $rss->channel->item;
$count = 0;
if($rss) {
foreach($items as $item) {
if($count <= 1) {
$title = $item->title;
$description = $item->description;
$link = $item->link;
$categories = $item->category;
foreach($categories as $category) {
if ($category == "$category_name") { ?>
<h3><a href="<?php echo $link; ?>"><?php echo $title; ?></a></h3>
<p><?php echo $description; ?></p>
<?php $count++;
}
}
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment