wp_list_filter

函式
wp_list_filter ( $list, $args = array(), $operator = 'AND' )
引數
  • (array) $list An array of objects to filter.
    Required:
  • (array) $args Optional. An array of key => value arguments to match against each object. Default empty array.
    Required:
    Default: array()
  • (string) $operator Optional. The logical operation to perform. 'AND' means all elements from the array must match. 'OR' means only one element needs to match. 'NOT' means no elements may match. Default 'AND'.
    Required:
    Default: 'AND'
返回值
  • (array) Array of found values.
定義位置
相關方法
list_fileswp_list_userswp_delete_filewp_insert_termwp_list_categories
引入
3.1.0
棄用
-

wp_list_filter: 這個函式根據使用者的輸入為列表中的專案建立一個過濾器。它提供了一個方便的方法,讓使用者根據特定的標準來過濾一個專案的列表。

根據一組key => value引數,過濾一個物件的列表。

檢索列表中符合給定引數的物件。key代表屬性名稱,value代表屬性值。

如果一個物件有比引數中指定的更多的屬性,這不會使它失去資格: 當使用’AND’運算子時,任何缺失的屬性都會使它失去資格。

如果你想從所有匹配的物件中獲取一個特定的欄位,請使用wp_filter_object_list()代替。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
return wp_filter_object_list( $list, $args, $operator );
}
function wp_list_filter( $list, $args = array(), $operator = 'AND' ) { return wp_filter_object_list( $list, $args, $operator ); }
function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
	return wp_filter_object_list( $list, $args, $operator );
}

常見問題

FAQs
檢視更多 >