fetch_feed

Advertisement

Summery Summery

Build SimplePie object based on RSS or Atom feed from URL.

Syntax Syntax

fetch_feed( string|string[] $url )

Parameters Parameters

$url

(Required) URL of feed to retrieve. If an array of URLs, the feeds are merged using SimplePie's multifeed feature. See also http://simplepie.org/wiki/faq/typical_multifeed_gotchas

Return Return

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

Source Source

File: wp-includes/feed.php

function feed_content_type( $type = '' ) {
	if ( empty( $type ) ) {
		$type = get_default_feed();
	}

	$types = array(
		'rss'      => 'application/rss+xml',
		'rss2'     => 'application/rss+xml',
		'rss-http' => 'text/xml',
		'atom'     => 'application/atom+xml',
		'rdf'      => 'application/rdf+xml',
	);

	$content_type = ( ! empty( $types[ $type ] ) ) ? $types[ $type ] : 'application/octet-stream';

	/**
	 * Filters the content type for a specific feed type.
	 *
	 * @since 2.8.0
	 *
	 * @param string $content_type Content type indicating the type of data that a feed contains.
	 * @param string $type         Type of feed. Possible values include 'rss', rss2', 'atom', and 'rdf'.
	 */
	return apply_filters( 'feed_content_type', $content_type, $type );
}

/**
 * Build SimplePie object based on RSS or Atom feed from URL.
 *
 * @since 2.8.0
 *
 * @param string|string[] $url URL of feed to retrieve. If an array of URLs, the feeds are merged
 *                             using SimplePie's multifeed feature.
 *                             See also {@link http://simplepie.org/wiki/faq/typical_multifeed_gotchas}
 * @return SimplePie|WP_Error SimplePie object on success or WP_Error object on failure.
 */
function fetch_feed( $url ) {
	if ( ! class_exists( 'SimplePie', false ) ) {
		require_once ABSPATH . WPINC . '/class-simplepie.php';
	}

Advertisement

Changelog Changelog

Changelog
Version Description
2.8.0 Introduced.

Advertisement

Leave a Reply