WP_Query::is_feed() WordPress Method

The WP_Query::is_feed() method is used to check if the current query is for a feed. This is useful for making sure that the correct template is used for displaying a feed.

WP_Query::is_feed( string|string[] $feeds = '' ) #

Is the query for a feed?


Parameters

$feeds

(string|string[])(Optional) Feed type or array of feed types to check against.

Default value: ''


Top ↑

Return

(bool) Whether the query is for a feed.


Top ↑

Source

File: wp-includes/class-wp-query.php

	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 );
	}


Top ↑

Changelog

Changelog
VersionDescription
3.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More