wp_list_filter [ WordPress Functions ]
wp_list_filter ( $list, $args = array(), $operator = 'AND' )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
| Codex |
Filters a list of objects, based on a set of key => value arguments.
Source
function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
if ( ! is_array( $list ) )
return array();
if ( empty( $args ) )
return $list;
$operator = strtoupper( $operator );
$count = count( $args );
$filtered = array();
foreach ( $list as $key => $obj ) {
$to_match = (array) $obj;
$matched = 0;
foreach ( $args as $m_key => $m_value ) {
if ( array_key_exists( $m_key, $to_match ) && $m_value == $to_match[ $m_key ] )
$matched++;
}
if ( ( 'AND' == $operator && $matched == $count )
|| ( 'OR' == $operator && $matched > 0 )
|| ( 'NOT' == $operator && 0 == $matched ) ) {
$filtered[$key] = $obj;
}
}
return $filtered;
}Examples [ wp-snippets.com ]
Top Google Search Results
- Function Reference/wp list filter « WordPress Codex
Description. Filters a list of objects, based on a set of key => value arguments. Usage. <?php wp_list_filter( $list, $args, $operator ); ?> Parameters. $list: (array) ...
codex.wordpress.org - wp_list_filter (WordPress Function) - WPSeek.com
Jun 9, 2013 ... Filters a list of objects, based on a set of key => value arguments. WordPress lookup for wp_list_filter, a WordPress Function.
wpseek.com - Exclude One Category and its Subcategories using WP_LIST_FILTER
Jun 25, 2012 ... I need to exclude a category and its subcategories in posts. This is the code I'm working on and it works: <?php $categories ...
wordpress.stackexchange.com - WordCamp NYC 2012: Moving Beyond the Codex: Learning ...
Catch-all files. functions.php. wp_list_filter(); wp_list_pluck(); wp_parse_args(). general-template.php. get_header(); get_sidebar(); single_*_title() ...
thinkoomph.com
