Tribe__Utils__Post_Collection::pluck( string $key, bool $single = true, array $args = null )

Plucks a post field, a taxonomy or a custom field from the collection.

Parameters #


(string) (Required) The name of the field to pluck; the method will try to detect the type of field from its name. If any issues might arise due to fields of different types with the same name, then use the pluck_<type> methods directly.


(bool) (Optional) Whether to pluck a single taxonomy term or custom fields or an array of all the taxonomy terms or custom fields for each post.

Default value: true


(array) (Optional) A list of n optional arguments that will be passed down to the pluck_<type> methods. Currently only the the pluck_taxonomy will support one more argument to define the query arguments for the term query.

Default value: null

Top ↑

Return #

(array<string>|array<array>) Either an array of plucked fields when plucking post fields or single custom fields or taxonomy terms, or an array of arrays, each one a list of all the taxonomy terms or custom fields entries for each post.

Top ↑

Source #

File: src/Tribe/Utils/Post_Collection.php

	public function pluck( $key, $single = true, array $args = null ) {
		$type = $this->detect_field_type( $key );

		switch ( $type ) {
			case 'post_field':
				return $this->pluck_field( $key );
			case 'taxonomy':
				return $this->pluck_taxonomy( $key, $single, $args );
				return $this->pluck_meta( $key, $single );

Top ↑

Changelog #

Version Description
4.12.6 Introduced.