Are there any query utilities/helpers available?

Created by Phil Kurth, Modified on Fri, 5 Aug, 2022 at 12:04 PM by Phil Kurth

There aren't any utilities for querying data, yet.

At the moment, the plugin intercepts calls made to ACF's get_field(), the_field(), update_field() etc functions and plugs data in from the custom tables. So, it's a seamless API when using ACF in a template context. 

The benefit of having the data structured is that you can use WordPress' $wpdb instance to query the data in any way you need — this is where the real performance gains come into it, especially when searching/filtering across many different fields. 

I have a simple example of using custom table data in conjunction with WP_Query here:

There are also a number of filters within WP_Query that allow adding clauses such as JOIN and WHERE clauses. I don't have a polished example of how to use these just yet but I do have a Gist you might like to have a peek at: 

If custom SQL is new to you, you might also want to start with the primer I wrote for SQL & WordPress: 

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article