Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 736

Refers to a mechanism built into the WP_Query class for querying the database for post data, including pages and CPTs, based upon post meta data.

1 vote
Accepted

meta_query problem

Meta queries aren't intended for filtering which posts are returned. You can use them this way, but the database isn't optimised for it. There are few things worse for scaling and performance than met …
Tom J Nowell's user avatar
  • 60.6k
0 votes
Accepted

How to send variable to wp meta_query value?

Use get_the_title to get the title. the_title is for when you want to output directly to the browser.
Tom J Nowell's user avatar
  • 60.6k
0 votes

How to properly escape values in meta query

The problem is that you've interpreted wpdb::esc_like as a literal copy paste, and not a direction, and used it as a static function, when it is not a static function. Good: global $wpdb; $foo = $wpdb …
Tom J Nowell's user avatar
  • 60.6k
1 vote
Accepted

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 …
Tom J Nowell's user avatar
  • 60.6k
1 vote

How can I change my meta_query to SQL wpdb query?

Several things, Firstly you can add the following for pagination: 'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ) This removes the need for the array_merge. Otherwise your existi …
Tom J Nowell's user avatar
  • 60.6k
4 votes
Accepted

Slow meta query with multi meta keys

The problem here is that post meta wasn't designed for these kinds of searches, that's why the taxonomy tables exist, else categories and tags would be stored as post meta Post meta is optimised for …
Tom J Nowell's user avatar
  • 60.6k
1 vote
Accepted

it's possible make a WP_Query with math operations?

No, not without using filters to insert raw SQL, you can do comparisons, such as greater than, smaller than, but not ranges, but even then this will be an incredibly slow query, doing it is a bad idea …
Tom J Nowell's user avatar
  • 60.6k
1 vote

Fetch all data of Users

There's been a fundamental misunderstanding of how meta_query works. meta_query is meant to be an array, not a new WP_User_Query. This is what you've done: get_users( [ ...args 'meta_query' => …
Tom J Nowell's user avatar
  • 60.6k
1 vote
Accepted

Tax query clause inside a meta query clause?

So, I need to run a Tax query inside a Meta query clause. This does not seem to be possible with the 'meta_query' argument, something like this: Correct, what you want to do is not possible using th …
Tom J Nowell's user avatar
  • 60.6k
0 votes
Accepted

Wordpress, fetching users with an exact match in a string of comma separated values in user_...

You can't do this in a query with that kind of data. The only way to truly do it is to retrieve all users, and manually process them in PHP to find the ID. Otherwise, you will get false positives such …
Tom J Nowell's user avatar
  • 60.6k
1 vote

meta_query for keys that aren't yet set

The simplest method, albeit not the cleanest: $args = array( 'post_type' => 'gallery', 'posts_per_page' => -1, 'meta_key' => 'gal-ID', 'order_by' => 'meta_value', 'order' => 'ASC' …
Tom J Nowell's user avatar
  • 60.6k
1 vote
Accepted

How to get sum of meta_values of a meta_key in wp_query according to conditions

WP_Query gets posts from the database, but it's not a generic SQL query class, it should really be called WP_Post_Query, as WP_Query implies it can do any SQL. As a result, you need to do several thi …
Tom J Nowell's user avatar
  • 60.6k
0 votes

Trouble with calling an imploded variable in an array

This is your problem: $follow_ids = $wpdb->get_results( "SELECT meta_value FROM brilli_usermeta WHERE user_id = ".$user_id ); No meta key is specified, and it's a raw SQL query, which means all use …
Tom J Nowell's user avatar
  • 60.6k
0 votes
Accepted

Why can my filter query SOME metadata but not other metadata?

Your query should work as is. To test this, I created 4 posts, and then using WP CLI, ran: wp post meta add 10 boxzilla_options "testingtesting123" Where post 10 is a post with the title test. 3 ot …
Tom J Nowell's user avatar
  • 60.6k
1 vote

get_users with array as meta_value

First, can use meta_query, but, you should change your values to use the proper date format, e.g. 2020/01/02 for January 2nd, rather than a regional format. See https://en.wikipedia.org/wiki/ISO_8601 …
Tom J Nowell's user avatar
  • 60.6k

15 30 50 per page