Tribe__Utils__Post_Collection::pluck_taxonomy( string $taxonomy, bool $single = true, array $args = null )

Plucks taxonomy terms assigned to the posts in the collection.

Note: there is no check on the taxonomy being an existing one or not; that responsibility is on the user code.

Parameters #


(string) (Required) The name of the post taxonomy to pluck terms for.


(bool) (Optional) Whether to return only the first results or all of them.

Default value: true


(<span class="arrayarray<string,string|">array>) (Optional) A set of arguments as supported by the WP_Term_Query::__construct method.

Default value: null

Top ↑

Return #

(array<mixed>|array<array>) Either an array of the requested results if $single is true or an array of arrays if $single is false.

Top ↑

Source #

File: src/Tribe/Utils/Post_Collection.php

	public function pluck_taxonomy( $taxonomy, $single = true, array $args = null ) {
		$plucked = [];
		$args    = null === $args ? [ 'fields' => 'names' ] : $args;

		foreach ( $this as $item ) {
			$terms     = wp_get_object_terms( $item->ID, $taxonomy, $args );
			$plucked[] = $single ? reset( $terms ) : $terms;

		return $plucked;

Top ↑

Changelog #

Version Description
4.12.6 Introduced.