| 1 |
# Advanced Query Loop |
| 2 |
|
| 3 |
 |
| 4 |
 |
| 5 |
 |
| 6 |
|
| 7 |
## Description |
| 8 |
|
| 9 |
This plugin introduces a Query Loop block variation that will empower users to be able to do much more complicated queries with the Query Loop block, such as taxonomy queries, post meta queries, date queries, post ordering, and more |
| 10 |
|
| 11 |
### Support/Issues |
| 12 |
|
| 13 |
Please use the either the [](https://wordpress.org/support/plugin/advanced-query-loop/support](https://wordpress.org/support/plugin/advanced-query-loop/](https://wordpress.org/support/plugin/advanced-query-loop/) forum or the [](https://github.com/ryanwelcher/advanced-query-loopofficial repository](https://github.com/ryanwelcher/advanced-query-loop](https://github.com/ryanwelcher/advanced-query-loop) for any questions or to log issues. |
| 14 |
|
| 15 |
### Available Controls |
| 16 |
|
| 17 |
Controls are organized into grouped panels in the block inspector: AQL: Post, AQL: Taxonomy, AQL: Meta, AQL: Date, AQL: Order by, AQL: Performance, and AQL: Advanced. A trailing **AQL: Extensions** panel appears only when a third-party extension has registered controls via the AQL SlotFills. |
| 18 |
|
| 19 |
#### Taxonomy queries |
| 20 |
|
| 21 |
Build complicated taxonomy queries! |
| 22 |
|
| 23 |
#### Multiple post types |
| 24 |
|
| 25 |
Select additional post types for your query! |
| 26 |
|
| 27 |
#### Include Posts |
| 28 |
|
| 29 |
Choose the posts you want to display manually or only the children of the current content. |
| 30 |
|
| 31 |
#### Exclude current post |
| 32 |
|
| 33 |
Remove the current post from the query. |
| 34 |
|
| 35 |
#### Exclude posts list |
| 36 |
|
| 37 |
Curate a list of posts to exclude from the query. |
| 38 |
|
| 39 |
#### Post Meta Query |
| 40 |
|
| 41 |
Generate complicated post meta queries using an interface that allows you to create a query based on `meta_key`, `meta_value` and the `compare` options. Combine multiple queries and determine if they combine results (OR) or narrow them down (AND). |
| 42 |
|
| 43 |
#### Date Query |
| 44 |
|
| 45 |
Query items before/after the current or a selected date, or choose to show posts from the last 1, 3, 6 or 12 months. |
| 46 |
|
| 47 |
#### Post Order controls |
| 48 |
|
| 49 |
Sort in ascending or descending order by: |
| 50 |
|
| 51 |
- Author |
| 52 |
- Comment Count |
| 53 |
- Date |
| 54 |
- Included Posts |
| 55 |
- Last Modified Date |
| 56 |
- Menu Order (props to @jvanja) |
| 57 |
- Meta Value |
| 58 |
- Meta Value Num |
| 59 |
- Name (props @philbee) |
| 60 |
- Post ID (props to @markhowellsmead) |
| 61 |
- Random |
| 62 |
- Title |
| 63 |
|
| 64 |
Order by multiple properties (primary + secondary sort), including meta values; posts without the meta key sort last in descending order. Multi-property ordering (the meta sort key and the secondary sort) applies to non-inherited queries only — when `Inherit query from template` is enabled, only the primary order and direction are used. |
| 65 |
|
| 66 |
#### Disable Pagination |
| 67 |
|
| 68 |
Improve the performance of the query by disabling pagination. |
| 69 |
|
| 70 |
#### Enable Caching |
| 71 |
|
| 72 |
Store query results in a transient for one hour to reduce database load on subsequent page loads. The caching toggle is unavailable when the order is set to Random, and switching to Random order will clear any existing caching setting. Found in the **AQL: Performance** panel. |
| 73 |
|
| 74 |
## Filtering the available controls |
| 75 |
|
| 76 |
It is possible to remove controls from AQL using the `aql_allowed_controls` filter. The filter receives a single parameter containing an array of allowed controls. This can be modified to remove the control from the UI and stop processing the associated query param. |
| 77 |
|
| 78 |
```php |
| 79 |
add_filter( |
| 80 |
'aql_allowed_controls', |
| 81 |
function( $controls ) { |
| 82 |
// Exclude the additional_post_types and taxonomy_query_builder controls. |
| 83 |
$to_exclude = array( 'additional_post_types', 'taxonomy_query_builder' ); |
| 84 |
$filtered_controls = array_filter( |
| 85 |
$controls, |
| 86 |
function( $control ) use ( $to_exclude ) { |
| 87 |
if ( ! in_array( $control, $to_exclude, true ) ) { |
| 88 |
return $control; |
| 89 |
} |
| 90 |
}, |
| 91 |
); |
| 92 |
return $filtered_controls; |
| 93 |
} |
| 94 |
); |
| 95 |
``` |
| 96 |
|
| 97 |
### List of control identifiers |
| 98 |
|
| 99 |
- `'additional_post_types'` |
| 100 |
- `'taxonomy_query_builder'` |
| 101 |
- `'post_meta_query'` |
| 102 |
- `'post_order'` |
| 103 |
- `'exclude_current_post'` |
| 104 |
- `'exclude_posts'` |
| 105 |
- `'include_posts'` |
| 106 |
- `'child_items_only'` |
| 107 |
- `'date_query_dynamic_range'` |
| 108 |
- `'date_query_relationship'` |
| 109 |
- `'pagination'` |
| 110 |
- `'enable_caching'` |
| 111 |
- `'query_id'` |
| 112 |
|
| 113 |
## Extending AQL |
| 114 |
|
| 115 |
Detailed instructions on how to extend AQL as well as an example are available [](./extending-aql.mdhere](./extending-aql.md](./extending-aql.md) |
| 116 |
|