Question

I am using Simple Pie To display content from multiple RSS Feeds.

I have successfully been able display the contents of the RSS Feeds. What I want now is to display the author name or Feed Title.

Example:

This is the RSS Feed URL: http://aaron.dietfreelife.com/feed/

I want to be able to retrieve the Feed Title as shown in the diagram attached.

retrieve the Feed Title

Here is my code spec:

<?php
foreach ($feed->get_items() as $item):
?>

<div class="item">
   <h2><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2>
   <p><?php echo $item->get_description(); ?></p>   
   <p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p>
</div>
<?php endforeach; ?>

Any help will be appreciated....

Was it helpful?

Solution

I believe it's something like this:

foreach ($feed->get_items() as $item) {
   $item->get_feed()->get_title()
   // or if you need more than one thing from the feed like permalink
   $parent_feed = $item->get_feed();
   $parent_feed->get_title();
   $parent_feed->get_permalink();
}

The documentation shows it being used in the feed constructor, but I use it this way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top