fetch_feed()
returns a WP_Error() if the feed in question does not exist or fails for whatever reason. If we’re only checking for failure we can check if the returned object is_wp_error()
.
if ( ! is_wp_error( $rss ) ){
// Assume the best, show feed
}
else{
// Assume the worst, show message
}
If the feed does return valid but is empty, we can do what you’re currently doing which is to try and get items from the valid feed:
$maxitems = $rss->get_item_quantity(1);
If $maxitems
is empty or 0, then we know the feed is a valid, but empty.
Related Posts:
- How to remove feeds from WordPress totally?
- Getting /feed/ behind post urls in Google Webmaster Tools; crawler errors? [closed]
- Disable comments feed, but not the others
- How to read the xml file in wordpress?
- Is it usual to have a non-Feedburner feed on a WordPress blog?
- Disable links in header (feeds and such)
- Troubleshooting fetch_feed and SimplePie
- How to exclude posts of a certain format from the feed
- Combining RSS Feeds and Sorting with fetch_feed
- wp_remote_get vs. fetch_feed ? which is the better for performance?
- how to publish a feed of posts with a certain custom field value?
- Combining multiple RSS feeds using fetch_feed
- Yoast custom feed template as add_feed function?
- Restrict certain posts from being sent to the feed subscribers
- How to display LinkedIn feed/company updates into WordPress site? [closed]
- Duplicate Posts using Feedwordpress
- Is there a way to have a dual WP feed (full/partial)?
- Custom WordPress Feeds operators?
- How to retrieve the list of all posts ever published via the feed?
- Update feed more frequently
- w3 total cache keeps minifying my feeds
- How to use is_feed() to target a category feed?
- Adding a featured image to atom feed
- Add custom profile info into Feed
- How to filter out an iframe from feed
- combine multiple feeds with fetch_feed and display blog titles for each item?
- RSS feed validity and Google Adsense
- Possible to get feed to return latest updated posts rather than latest published?
- Removing the FeedBurner redirect
- Options for authenticated feeds
- RSS feed for deleted posts and comments
- Server stressed by /feed
- How to get feed for pages?
- How can i realize a semi-private research diary blog
- WordPress feeds and publish date
- Editing feed for thumbnails and link
- feed appearing different in the three main browsers
- Fetch_Feed cURL error 28
- Using fetch_feed to retrieve items with non common titles
- How to output WordPress feed in a non-WordPress site?
- Change conditionally a variable value for different feeds
- fetch_feed Performance Issue
- Googlebot adding /feed at the end of my URLs
- How can I set my RSS feed time to update feed quicker
- Why is my comment feed broken?
- Require authorization for access to RSS feeds, but leave posts public
- after server upgrade, if I enable custom permalinks, my /feed stops working
- Using links (link_rss field) as the source for fetch_feed
- wordpress feed link change
- Why I don’t see all my post in feed in WordPress
- How can I force fetch_feed to return real URL?
- Default Wordress RSS Widget does not work on a subdomain site, works when I move it
- Expire Header for custom XML feed
- My RSS feed is not working
- How to remove feeds from WordPress totally?
- a lot of errors with feedwordpress
- Does the FD Feedburner plugin create feeds for categories
- fetch_feed function works on template index.php but not in plugin/wp-admin
- Conditional tag to show content in custom rss feed?
- Need correct results from 6 rss (fetch_feed)
- How can I rename the element to in my RSS?
- Password Protect a Podcast Feed?
- How to fetch all the movie details from IMDB
- Does it makes sense to have {post}/feed?
- Custom RSS causing timeout for website
- Rewrite custom post type rss feed links
- How to check if feed URL was requested?
- Feed 404 Errors
- Disable Comments Feed
- Insert Featured image from Feed
- Adding posts of custom type into the main feed
- How can I remove certain HTML tags from the RSS feed?
- How to make custom post type feed title = taxonomies?
- Include only recents custom posts in WP rss feed
- Addition Text to Post Titles (Custom Post Types) in RSS
- .htaccess rewriting old RSS feed URL to WordPress feed URL
- How do I get link URLs from the WordPress links backend into an array?
- 404 in custom post type feed with mistake permalink
- Custom JSON feed rewrite
- Properly setting up a feed
- Access category within rss2_head hook?
- add_feed rewrite overwriting standard permalinks
- RSS/Atom feeds invalid, “Mismatched tag” errors
- How to Define Custom Number of Items in Comment Feed
- wp-includes does not contain a feed template
- Publish a Silent Post without updating Feed
- How to change permalink on headlines in rss feeds?
- WordPress won’t let me use a page slug of ‘feed’
- My WordPress installation isn’t updating the feed when a new post is published
- How to fetch common posts from two feeds?
- WordPress create custom XML RSS feed template
- How to get a list of articles related to a particular category from my other WordPress website?
- Custom WordPress feed on Apache server returning 304 response for if-modified-since
- On my WordPress 5.4 website, how to remove all feeds? Including Category and Tags
- WordPress feed only shows first page of category
- Weird characters in title if it contain “ ”
- RSS feed url showing page not found. How to solve it?
- RSS2 Feed with two CDATA sections
- How to remove certain feed from my dashboard in WP admin
- “feed” added at the end of my URLs