WP_Query::is_feed()publicWP 3.1.0

Determines whether the query is for a feed.

Method of the class: WP_Query{}

No Hooks.

Return

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.5.2

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

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

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