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 #
- $key
-
(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. - $single
-
(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
- $args
-
(array) (Optional) A list of n optional arguments that will be passed down to the
pluck_<type>
methods. Currently only the thepluck_taxonomy
will support one more argument to define the query arguments for the term query.Default value: null
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.
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 ); break; case 'taxonomy': return $this->pluck_taxonomy( $key, $single, $args ); break; default: return $this->pluck_meta( $key, $single ); break; } }
Changelog #
Version | Description |
---|---|
4.12.6 | Introduced. |