# Ajax Filter Sort

**Lets users sort results by different criteria.**

**Content > Query Settings**

| Setting          | Description                              |
| ---------------- | ---------------------------------------- |
| **Query Name**   | Must match your Main Query               |
| **Sort Options** | Define available sort options (repeater) |

**Sort Option Settings**

Each sort option has:

| Setting         | Description                                                                 |
| --------------- | --------------------------------------------------------------------------- |
| **Label**       | Display text (e.g., "Newest First")                                         |
| **Source Type** | Built-in Field, Custom Field (Text), Custom Field (Numeric)                 |
| **Field**       | For built-in: Title, Date, Modified Date, Menu Order, Random, Comment Count |
| **Meta Key**    | For custom fields                                                           |
| **Order**       | ASC or DESC                                                                 |

**Content > General Settings**

| Setting               | Description                               |
| --------------------- | ----------------------------------------- |
| **Layout Type**       | Dropdown, Radio, or Button                |
| **Placeholder**       | Dropdown placeholder                      |
| **Hide 'All' Option** | Hide default/reset option                 |
| **Label: All**        | Text for default option (e.g., "Default") |
| **Legend Label**      | Accessibility label                       |
| **Apply On**          | Input or Submit                           |

**Default Sort Options**

The element comes with these presets:

* Newest First (date DESC)
* Oldest First (date ASC)
* Title A-Z (title ASC)
* Title Z-A (title DESC)

**Usage Example**

```
Product Sort:
1. Add Ajax Filter Sort
2. Query Name: "products"
3. Sort Options:
   - "Price: Low to High" | meta_value_num | _price | ASC
   - "Price: High to Low" | meta_value_num | _price | DESC
   - "Newest" | built_in | date | DESC
4. Layout: Dropdown
5. Placeholder: "Sort by..."
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.woohoo.dance/ajax-filters/elements/ajax-filter-sort.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
