admin管理员组

文章数量:1391918

I use the exact same code from Wordpress codex here :

It works as intended with most external RSS i tried to use but for one of them i have the error

A feed could not be found at RSS-URL. A feed with an invalid mime type may fall victim to this error, or SimplePie was unable to auto-discover it.. Use force_feed() if you are certain this URL is a real feed.

I can't find any information on how to use force_feed with the code $rss = fetch_feed('RSS-URL');, and i'm 100% sure the external rss code is valid. I think the problem from the RSS is the content type which is xml and not rss+xml.

Any help appreciated, thanks !

I use the exact same code from Wordpress codex here : https://codex.wordpress/Function_Reference/fetch_feed#Example

It works as intended with most external RSS i tried to use but for one of them i have the error

A feed could not be found at RSS-URL. A feed with an invalid mime type may fall victim to this error, or SimplePie was unable to auto-discover it.. Use force_feed() if you are certain this URL is a real feed.

I can't find any information on how to use force_feed with the code $rss = fetch_feed('RSS-URL');, and i'm 100% sure the external rss code is valid. I think the problem from the RSS is the content type which is xml and not rss+xml.

Any help appreciated, thanks !

Share Improve this question asked Jul 20, 2016 at 14:26 Aurélien GrimpardAurélien Grimpard 1131 silver badge5 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

If we peek into the fetch_feed() function we see the instantiation:

$feed = new SimplePie();

where the object is made accessible through the wp_feed_options hook via:

do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );

where $feed is passed by reference.

This means we can adjust that object instance through the hook, before the $feed->init() is called within fetch_feed().

I searched this site for examples for you and found only one here by @Firsh. that sets $feed->force_feed(true) through the wp_feed_options hook.

本文标签: rssHow to use forcefeed with fetchfeed