How do I access the channel data when using fetch_feed()? I want to use the channel title.


Further info:

A typical RSS feed (taken from wikipedia)

  <?xml version="1.0" encoding="UTF-8" ?>
  <rss version="2.0">
 <title>RSS Title</title>
 <description>This is an example of an RSS feed</description>
 <copyright>2020 Example.com All rights reserved</copyright>
 <lastBuildDate>Mon, 6 September 2010 00:01:00 +0000</lastBuildDate>
 <pubDate>Sun, 6 September 2009 16:20:00 +0000</pubDate>

  <title>Example entry</title>
  <description>Here is some text containing an interesting description.</description>
  <guid isPermaLink="false">7bd204c6-1655-4c27-aeee-53f933c5395f</guid>
  <pubDate>Sun, 6 September 2009 16:20:00 +0000</pubDate>


I wish to extract and use the channel title instead of the item title (because the mastodon feed doesn't use them currently).

I can access the data in <item> but accessing parts of <channel> I can't work out.

Does that help?

  • can you describe what you meant by channel? Is this a standard RSS feed of posts/entries or something else? I'm not seeing code in your question that can be modified either
    – Tom J Nowell
    Dec 1, 2022 at 10:20
  • Added information above.
    – skribe
    Dec 1, 2022 at 11:35
  • According to the documentation fetch_feed() returns a SimplePie object, and a very quick search for "SimplePie channel" returns simplepie.org/wiki/reference/simplepie/get_channel_tags. Have you tried that? Dec 1, 2022 at 12:08
  • ooooh you're trying to display mastodon toots and want to grab the profile name from the main title
    – Tom J Nowell
    Dec 1, 2022 at 12:25
  • 1
    I expect that by the time I work out the vagaries of developing a wordpress plugin, Mastodon will have fixed their feed mechanics. But it's a good learning process. I just wish the documentation was more helpful. Cheers!
    – skribe
    Dec 2, 2022 at 2:50

1 Answer 1


The official WP docs say it returns a SimplePie object and the very first example in the SimplePie documentation is:

// Single feed
$feed = new SimplePie('http://simplepie.org/blog/feed/', $_SERVER['DOCUMENT_ROOT'] . '/cache');
echo $feed->get_title();


$feed is the same type of object as the return value of fetch_feed:


SimplePie|WP_Error SimplePie object on success or WP_Error object on failure.


Just make sure to call is_wp_error to check for failures

  • Thank you very much.
    – skribe
    Dec 2, 2022 at 2:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.