# Post type select

Post type select field renders a searchable [Select 2](https://select2.github.io/) field that will provide a list of post type titles when a user has typed at least two characters (the values will be loaded dynamically). Similar to the [Datalist](/fields/datalist.md) field. Supports [multiple choice](/fields/post-type-select.md#multiple-choice).

## Description

The field uses [AJAX](https://developer.mozilla.org/en/docs/AJAX) to load the values dynamically, so depending on your configuration, there may be some latency before the results are presented to the user. Uses the [Search Parameter](https://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter) of the `WP_Query` class on the back end.

## Example configuration

```php
...
array(
    'title' => 'My post type select field title',
    'id' => 'post-type-select-option',
    'desc' => 'Short description for the field',
    'tab' => 'main',
    'post-type' => 'page',
    'type' => 'post-type-select',
),
...
```

This will produce the following

![](/files/-LKMTppZrflVyd4WNd8J)

## Multiple choice

if `'multiple' => true` is added to the [configuration object](/fields/post-type-select.md#example-configuration), the field will respect it. The following configuration

```php
...
array(
    'title' => 'My post type select field title',
    'id' => 'post-type-select-option',
    'desc' => 'Short description for the field',
    'tab' => 'main',
    'post-type' => 'page',
    'multiple' => true,
    'type' => 'post-type-select',
),
...
```

will result in the following

![](/files/-LKMTppatKvp8cji-rGj)

## Params

| Name        | Type    | Description                                                                                                       |
| ----------- | ------- | ----------------------------------------------------------------------------------------------------------------- |
| `type`      | string  | `post-type-select` **(required)**                                                                                 |
| `id`        | string  | Unique ID that will be used to retrieve the value **(required)**                                                  |
| `tab`       | string  | Specifies in which tab this option will be rendered                                                               |
| `title`     | string  | Shows a heading to the left of the field                                                                          |
| `desc`      | string  | Shows a description text (can have HTML)                                                                          |
| `multiple`  | boolean | Set to `true` if multiple values are needed. See [an example](/fields/post-type-select.md#multiple-choice) above. |
| `post-type` | string  | Post type (standard or custom) to search for. If not specified, searches posts of the `post` type.                |


---

# 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.alchemy-options.com/fields/post-type-select.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.
