construct complex queries with WP User Query

$meta_query_args = array( ‘meta_query’ => array( ‘relation’ => ‘OR’, // Optional, defaults to “AND” array( ‘key’ => ‘_my_custom_key’, ‘value’ => ‘Value I am looking for’, ‘compare’ => ‘=’ ), array( ‘relation’ => ‘AND’, array( ‘key’ => ‘_my_custom_key_2’, ‘value’ => ‘Value I am looking for 2’, ‘compare’ => ‘=’ ), array( ‘key’ => ‘_my_custom_key_3’, ‘value’ => … Read more

WP_User_Query and user posts

If you pass in the fields parameter to your user query you can easily get an array of ids to the pass in to your wp query : //WP User Query $author_query = new WP_User_Query( array ( ‘number’ => 3, ‘fields’ => ‘ID’ )); $author_results = $author_query->results; //WP Query $postArgs = array ( ‘author__in’=> $author_results, … Read more

meta query based on month regardless of year

While the regexp solution will function, it quickly gets slower as the number of users increases. This is because the database cannot perform optimisation and indexing tricks, and forces a full table scan. The more users, and the more meta, the greater the cost of the query. At a minimum it requires caching to avoid … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)