WP_Term_Query::query() WordPress Method

The query() method is a wordpress method used to query for terms in a given taxonomy. The method accepts an array of arguments, which can be used to modify the query. The most common arguments are 'taxonomy', 'term', and 'field'.

WP_Term_Query::query( string|array $query ) #

Sets up the query and retrieves the results.


Description

The return type varies depending on the value passed to $args['fields']. See WP_Term_Query::get_terms() for details.


Top ↑

Parameters

$query

(string|array)(Required)Array or URL query string of parameters.


Top ↑

Return

(WP_Term[]|int[]|string[]|string) Array of terms, or number of terms as numeric string when 'count' is passed as a query var.


Top ↑

Source

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

	public function query( $query ) {
		$this->query_vars = wp_parse_args( $query );
		return $this->get_terms();
	}


Top ↑

Changelog

Changelog
VersionDescription
4.6.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.