I use the exact same code from Wordpress codex here : https://codex.wordpress.org/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 !


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.

  • Yes i finaly found a similar solution. Force feed now works but the feed still doesn't, Looks like i've to instigate deeper :) – Aurélien Grimpard Jul 21 '16 at 8:41
  • You might check if the feed is valid. Another thing that I've bumped into is trying to fetch feeds from other servers on the same network where there's a strict firewall between servers ;-) @AurélienGrimpard – birgire Jul 21 '16 at 8:47
  • Yes the feed is valid. I fetch externals rss from a very stict server, most of them works, only the one i want to use doesn't :) Will see with sysadmin if they can think of something ... – Aurélien Grimpard Jul 21 '16 at 10:01
  • You can check if it's accessible on your server with e.g. curl -I http://example.tld/feed/ or with some trace tools. Best of luck ;-) @AurélienGrimpard – birgire Jul 21 '16 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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