WP_Query::is_feedpublicWP 3.1.0

Determines whether the query is for a feed.

Method of the class: WP_Query{}

No Hooks.

Returns

true|false. Whether the query is for a feed.

Usage

global $wp_query;
$wp_query->is_feed( $feeds );
$feeds(string|string[])
Feed type or array of feed types to check against.
Default: ''

Changelog

Since 3.1.0 Introduced.

WP_Query::is_feed() code WP 6.9

public function is_feed( $feeds = '' ) {
	if ( empty( $feeds ) || ! $this->is_feed ) {
		return (bool) $this->is_feed;
	}

	$query_var = $this->get( 'feed' );
	if ( 'feed' === $query_var ) {
		$query_var = get_default_feed();
	}

	return in_array( $query_var, (array) $feeds, true );
}