You appear to be a bot. Output may be restricted
Description
Load posts by meta_key arrayNote: If there is only one value in the value_array we try to improve performance by simplifying the request to use meta_key rather than meta_query
Usage
$array = bw_get_by_metakey_array( $post_type, $meta_key, $value_array );
Parameters
- $post_type
- ( string ) required – the post type required
- $meta_key
- ( string ) required – the name of the meta value to match
- $value_array
- ( array ) required – the set of values to load. There may be only one
Returns
array $posts – the array of posts returnedSource
File name: oik/includes/bw_posts.phpLines:
1 to 29 of 29
function bw_get_by_metakey_array( $post_type, $meta_key, $value_array ) { $atts = array(); $atts['post_type'] = $post_type; $atts['numberposts'] = -1; if ( is_array( $value_array ) ) { if ( count( $value_array ) > 1 ) { $meta_query = array(); $meta_query[] = array( "key" => $meta_key , "value" => $value_array , "compare" => "IN" ); $atts['meta_query'] = $meta_query; } else { $atts['meta_key'] = $meta_key; $atts['meta_value'] = $value_array[0]; } } else { $atts['meta_key'] = $meta_key; $atts['meta_value'] = $value_array; /* * @TODO Is it safe to limit ourselves to a single API? * Or should this be controlled by the application? */ //$atts['numberposts'] = 1; } $atts['exclude'] = -1; $posts = bw_get_posts( $atts ); return( $posts ); }View on GitHub View on Trac