Querying by meta key and value

You can make use of REGEXP operator in META_COMPARE. For example: $meta_array[] = array( ‘key’ => ‘_item_allowed_companies’, ‘value’ => $allowed_company, ‘compare’ => ‘REGEXP’ ); $args = array( ‘post_type’ => ‘item’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => $posts_per_page, ‘paged’ => $paged, ‘meta_query’ => $meta_array ); References: WP_Query Custom Field parameters Trac ticket #18736

Display Users from two roles in one list

Since the roles for a user are stored in (dbprefix)_capabilities, I’d try grabbing the database prefix and then using it to grab people with the right capabilities (caps are in a serialized array): global $wpdb; $prefix = $wpdb->prefix; $meta_name = “{$prefix}capabilities”; ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => “{$meta_name}” ‘value’ => ‘program_manager’, ‘compare’ … Read more

How to fetch WP_User_Query with multiple role arguments [duplicate]

WP_User_Query only accepts a single ‘role’ argument, and since your array has the same key twice only the second is getting used: array( ‘role’ => ‘vendor’, ‘role’ => ‘freevendor’, ); Is the same as: array( ‘role’ => ‘freevendor’, ); You could make two calls, one for each role set: $user_query_args = array ( ‘role’ => … Read more

WP User Query with meta queries

Actually, I think your code says Where min_price >= $price and max_price <= $price. Try to switch the operands, like here: array( ‘key’ => ‘min_price’, ‘value’ => $price, ‘compare’ => ‘<=’, ‘type’ => ‘NUMERIC’ ), array( ‘key’ => ‘max_price’, ‘value’ => $price, ‘compare’ => ‘>=’, ‘type’ => ‘NUMERIC’ ), It works for 10.000 and 20.000 … Read more