3 votes
Accepted

Display no post when metavalue is 0

Here's an updated example that appears to do what you want. See the docs for meta queries for details. $query_args = [ 'post_type' => 'list', 'posts_per_page' => 3, 'orderby' ...
user avatar
2 votes
Accepted

Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args

The error happens because the filter callback (shapeSpace_disable_sitemap_post_meta()) expects to receive two parameters ($args and $post_type) and yet you call add_filter() without setting the fourth ...
user avatar
  • 33.1k
2 votes

Add indexing to meta_value in wp_postmeta

Ollie Jones is doing massive index upgrade work with https://wordpress.org/plugins/index-wp-mysql-for-speed/ right now. His current recommendation for modern Barracuda storage engine backed tables is ...
user avatar
  • 669
2 votes

How to use meta_query to check if a meta field has something set?

It seems the type of value is essential now. I couldn't get the meta query working correctly without using the type. Significantly, while checking the value existence. This code doesn't work now. '...
user avatar
2 votes
Accepted

How to pull all the contributer users records and order by Designation (which is users meta data)?

I got the answer after went through WP_User_Query documentation. Following is the final query: $args = [ 'role__not_in' => 'Administrator', 'meta_key' => 'designation', 'meta_query '=...
user avatar
2 votes

Fetch all data of Users

Actually since you already have the ID you could just loop through and get the meta. https://developer.wordpress.org/reference/functions/get_user_meta/ get_user_meta(ID)
user avatar
  • 175
1 vote
Accepted

Display posts with specific value first in query

If I understand it correctly, you would need to use the CASE operator in MySQL/MariaDB like so, to achieve that kind of sorting: (try a live demo on DB Fiddle) ORDER BY (CASE # put posts with the ...
user avatar
  • 33.1k
1 vote
Accepted

Sort by presence of thumbnail

Found it, and it is basically a combination of the two answers here and then following the tip to remove the meta_key key following WP Version 4.1 here (same post): $query_args = [ 'post_type' ...
user avatar
  • 529
1 vote

Sort by presence of thumbnail

Easy peasy! $args_for_query1 = [ 'post_type' => 'custom_project', 'post_status' => 'publish', 'meta_query' => array( array( 'key' => '_thumbnail_id' ...
user avatar
  • 151
1 vote

Why isn't my `meta_query` array functioning properly?

I already got it. Was missing an extra array() in the meta_query. My updated code is this: I'd like to thank this website. Sometimes just posting the question helps me figure it out. What a cool ...
user avatar
1 vote
Accepted

How to set up hierarchical relationships without using plugins / meta query

You should use taxonomies to store your relationships. Sidenote: A possible answer was to make the releases children of the artists using the classic post_parent field, however a post can only have 1 ...
user avatar
  • 53.3k
1 vote

Display post in order of ACF checkbox?

Given that this order you desire is unfortunately not alphabetical (although that wouldn't be very scaleable... but it would be handy). You might make life easier on yourself by adding another custom ...
user avatar
1 vote
Accepted

WP Query ordering on a meta field for posts with a date in the future not ordering by datetime

The docs are a little vague in this area, but it should be possible to define your ordering value more succinctly: $args = array( 'post_type' => 'post', 'post_status' => 'publish', ...
user avatar
  • 7,485
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' =&...
user avatar
  • 53.3k
1 vote
Accepted

ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?

New answer I now have a better understanding of the question thanks to OPs comment and have come up with the following. Not tested! global $wpdb; /** * @var string $field The flexible content field ...
user avatar
  • 588
1 vote
Accepted

WP_User_Query ignoring 'meta_query' arguments

But once I try to look for other meta values, the return bring all members in the DB. Are you sure the meta other than name did not work, i.e. all members/users were returned? Because as I could see ...
user avatar
  • 33.1k
1 vote
Accepted

last_name + first_name orderby with meta_query [solved]

To do this you need to use named meta query clauses according to the official developer docs for WP_Query: ‘orderby’ with multiple ‘meta_key’s If you wish to order by two different pieces of postmeta ...
user avatar
  • 53.3k
1 vote

Is this meta query problematic?

Short answer is: Big Meta Queries are incredibly bad and can quickly lead to the MySQL-Server not responding anymore. You should try to rework the meta_query to not have so many clauses. Long Answer: ...
user avatar
1 vote

Unable to use meta_query between currency values when value is over 1 million

UPDATE: Sorry, apparently my solution faces the same problem when the query contains values such as '$599,000' or '$1,149,000. so far, the only solution so far was cleaning the database imported data ...
user avatar
1 vote

Using meta query ('meta_query') with a search query ('s')

I found an clean solution in WordPress core. WordPress developers already had this problem for search in attachments _wp_attached_file meta and they fix this issue in this function: ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible