WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp filter object list

Contents

Description

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

Usage

<?php wp_filter_object_list$list$args$operator$field ); ?>

Parameters

$list
(array) (required) An array of objects to filter
Default: None
$args
(array) (optional) An array of key => value arguments to match against each object
Default: array()
$operator
(string) (optional) The logical operation to perform. 'or' means only one element from the array needs to match; 'and' means all elements must match. The default is 'and'.
Default: and
$field
(boolean|string) (optional) A field from the object to place instead of the entire object
Default: false

Return Values

(array) 
A list of objects or object fields

Examples

Filtering out certain post types from the loop following a search

If multiple post types are returned in a search query you can filter out the posts that are of post type 'page' only.

$pages = wp_filter_object_list( $wp_query->posts, array('post_type' => 'page'));


Change Log

Since: 3.0

Source File

wp_filter_object_list() is located in wp-includes/functions.php