Created
January 25, 2013 16:49
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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