Uma área de pesquisa sobre o WordPress para devs e autores do tema



wp_list_pluck ›

Desde3.1.0
Obsoleton/a
wp_list_pluck ( $list, $field, $index_key = null )
Parâmetros: (3)
  • (array) $list List of objects or arrays
    Required: Yes
  • (int|string) $field Field from the object to place instead of the entire object
    Required: Yes
  • (int|string) $index_key Optional. Field from the object to use as keys for the new array. Default null.
    Required: No
    Padrão: null
Retorna:
  • (array) Array of found values. If `$index_key` is set, an array of found values with keys corresponding to `$index_key`. If `$index_key` is null, array keys from the original `$list` will be preserved in the results.
Definido em:
Codex:
Log de mudanças:
  • 4.0.0
  • 4.7.0

Pluck a certain field out of each object in a list.

This has the same functionality and prototype of array_column() (PHP 5.5) but also supports objects.



Fonte

function wp_list_pluck( $list, $field, $index_key = null ) {
	$util = new WP_List_Util( $list );
	return $util->pluck( $field, $index_key );
}