WordPress at a glance

wp_filter_object_list() WP 1.0

Filters a list of objects, based on a set of key => value arguments.

Works based on: WP_List_Util::filter()
Basis of: get_post_stati()
1 time = 0.000001s = speed of light | 50000 times = 0.95s = very fast | PHP 7.1.11, WP 4.9.8

No Hooks.


Array. A list of objects or object fields.


wp_filter_object_list( $list, $args, $operator, $field );
$list(array) (required)
An array of objects to filter
An array of key => value arguments to match against each object.
Default: empty array
The logical operation to perform. 'or' means only one element from the array needs to match; 'and' means all elements must match; 'not' means no elements may match.
Default: 'and'
A field from the object to place instead of the entire object.
Default: false


Since 3.0.0 Introduced.
Since 4.7.0 Uses WP_List_Util class.

Code of wp_filter_object_list() WP 5.6

function wp_filter_object_list( $list, $args = array(), $operator = 'and', $field = false ) {
	if ( ! is_array( $list ) ) {
		return array();

	$util = new WP_List_Util( $list );

	$util->filter( $args, $operator );

	if ( $field ) {
		$util->pluck( $field );

	return $util->get_output();

From tag: array list help functions (sorting arrays objects)

More from category: Helper Functions

No comments
    Log In