get_users meta_query: REGEXP not working for matching new lines

I found the problem and also fixed a bug in the regex. Final code: ‘meta_query’ => array( array( ‘key’ => ‘my_meta_field’, ‘value’ => “(^|\n|\r\n)99999($|\n|\r\n)”, ‘compare’ => ‘REGEXP’, ), ), The problem here was WordPress was adding extra backslashes on the special characters. By wrapping the expression in double quotes, this problem was solved. Also added … Read more

Query returning same results even though the ID changes

You can pass your meta query into query_posts or (the preferable) WP_Query in 2 ways: An array using the array keys meta_key, meta_value, meta_type and meta_compare An array of arrays using the array keys key, value, type and compare In your question, you were trying to use a mix of the two, and that’s why … Read more

Meta query date column add [x] days to validate

On top of my head this should be something like: ‘meta_query’ => [ ‘key’ => ‘_EventEndDate’, ‘value’ => [ $start, $end ], ‘compare’ => ‘BETWEEN’, ‘type’ => ‘DATETIME’ ] You would need to calculate boundaries yourself before passing to the query in this case. See Custom Field Parameters in Codex for full documentation on parameters … Read more

meta_query with multiple values optimization

Post meta data was never designed to be used efficiently in queries. Using it with LIKE based matching will only make it more horrible. You need to rethink your DB. For example use taxonomy terms to indicate which social network is associated with a post.

Query with meta_query and tax_query together not working properly

Tax query is formed wrong. It also array of arrays(queries) get_posts([ ‘meta_query’ => [ [ ‘key’ => ‘country’, ‘value’ => ‘Japan’, ‘compare’ => ‘LIKE’ ] ], ‘tax_query’ => [ [ ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => [‘kids’] ] ] ]); the array should look like this: Array ( [meta_query] => Array ( [relation] … Read more