In addition to the default, custom, and manual query options available for Easy Posts and Repeater elements, you can also choose the advanced option.
This query type allows you to visually build a query based off of WP_Query parameters and optionally, dynamic data from WordPress.
You can build virtually any type of query that WP_Query supports by using the advanced query option:
- Related posts by taxonomy
- Queries based on custom field values (e.g. ACF relationship fields)
- Author archive queries
- Child post queries
The advanced query option includes a few presets that cover some of these use-cases without having to manually configure the query.
Building Your Query
Note: advanced queries are an advanced topic and it's very helpful if you understand how WP_Query works. You can see a full list of WP_Query parameters, along with descriptions of their function, at https://www.billerickson.net/code/wp_query-arguments/.
To begin building your query, select your Easy Posts or Repeater element and navigate to the Query settings in the Properties Pane. Choose advanced and then, if you're not using a preset from the preset dropdown, click Edit Query.
You'll then see the Advanced Query modal. Begin building your query by clicking the blue Add Query Parameter button.
Next, choose the desired query parameter from the dropdown.
Once a parameter is chosen, click the Add Value button.
Depending on which parameter is chosen, you'll either be presented with a text input field or a dropdown. All text input fields in the Advanced Query modal can be populated with dynamic data by clicking the data button in a given field.
Some query parameters accept multiple values or multiple different types of values. One example of this is tax_query, which accepts an array of data to help identify the posts that should be returned.
Once array is chosen from the dropdown for the tax_query, you can then add values to the array itself to build the query.
As you can see from this example, it's possible to build very complex queries using the Advanced Query option. You can also add multiple query parameters to a query.
ACF Relationship Field
To use an ACF Relationship field, edit your Advanced Query and add the post__in parameter.
Next, add a value. Then click the data button in the parameter's value field.
In the Dynamic Data dialog, click Advanced Custom Field and then your ACF relationship field from the list of available fields.
On the next screen, make sure to put a single comma ( , ) in the separator field.
Next, click INSERT.
Now, close the Advanced Query dialog and click Apply Query Params button in the Properties Pane to see the result. Note that you must be previewing a post with a populated ACF relationship field in order to see the results as expected.
You can further narrow your query by adding post_type and other parameters to make it more efficient.