# 10. Autocomplete

**One of the most complicated fields and requires a post\_type array field - to suggest options for the user.**&#x20;

![](/files/-MQLwPSze-K5Hv9S9PdV)

![](/files/-MQLytNe9X7Zw7Bv9gVz)

```
'autocom' => array(
    'type' => 'autocomplete',
    'post_type' => array('post'),
    'label' => esc_html__('Post to choose', 'masterstudy-lms-learning-management-system'),
),
```

�But you can add your custom filter to suggested options - stm\_wpcfto\_autocomplete\_**autocom** where **autocom** is a key of a field. You should pass an array of items like this:

```
add_filter('stm_wpcfto_autocomplete_autocom', function ($r, $args) {

    $r = array(
        array(
            'id' => 1,
            'title' => 'Title 1',
            'post_type' => '',
        ),
        array(
            'id' => 2,
            'title' => 'Title 2',
            'post_type' => '',
        ),
        array(
            'id' => 'fewfewbfhewvbfewjhvfewg',
            'title' => 'Title 3 with rand -' . rand(),
            'post_type' => '',
        ),
        array(
            'id' => 4,
            'title' => 'Title 4 with rand -' . rand(),
            'post_type' => '',
        ),
    );

    return $r;

}, 10, 2);
```

�

![](/files/-MQM3Ay7fbXhlGFWVi7z)

![](/files/-MQM4gCubeAFl52efoWE)

If you need to limit added options you can add "limit" parameter to field

```
'limit' => 1
```

�


---

# 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.stylemixthemes.com/nuxy/fields/autocomplete.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.
