> For the complete documentation index, see [llms.txt](https://docs.acpt.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.acpt.io/developers/functions/acpt_field.md).

# acpt\_field

Display a field value

Render a field value through the `[acpt]`/`[acpt_tax]`/`[acpt_user]`/`[acpt_option]` shortcode machinery and **return** the rendered output as a string. Use [`get_acpt_field`](/developers/functions/get_acpt_field.md) if you want the raw value instead.

{% hint style="warning" %}
This function **returns** its output — it does not echo anything itself. `echo` it (or use it inside a template expression) to actually display something:

```php
echo acpt_field([
    'post_id'    => 123,
    'box_name'   => 'box',
    'field_name' => 'field',
]);
```

{% endhint %}

### Parameters

| Parameter              | Type              | Required                 | Description                                                                                     |
| ---------------------- | ----------------- | ------------------------ | ----------------------------------------------------------------------------------------------- |
| `post_id`              | integer           | Conditional              | The post ID                                                                                     |
| `term_id`              | integer           | Conditional              | The term ID                                                                                     |
| `user_id`              | integer           | Conditional              | The user ID                                                                                     |
| `comment_id`           | integer           | Not currently functional | Accepted, but see warning below                                                                 |
| `wc_product_attribute` | integer           | Conditional              | The WooCommerce product attribute ID                                                            |
| `option_page`          | string            | Conditional              | The option page slug                                                                            |
| `box_name`             | string            | Required                 | The meta box name                                                                               |
| `field_name`           | string            | Required                 | The field name                                                                                  |
| `date_format`          | string            | Optional                 | PHP date format string for Date, DateTime, and Date range fields. Also accepted as `dateFormat` |
| `time_format`          | string            | Optional                 | PHP time format string for Time and DateTime fields. Also accepted as `timeFormat`              |
| `width`                | string \| integer | Optional                 | Element width for Image, Video, and Gallery fields                                              |
| `height`               | string \| integer | Optional                 | Element height for Image, Video, and Gallery fields                                             |
| `target`               | string            | Optional                 | Link target attribute for URL fields. One of `_blank`, `_self`, `_parent`, `_top`               |
| `sort`                 | string            | Optional                 | Sort order for multi-value fields (e.g. Gallery, Checkbox). One of `asc`, `desc`, `rand`        |
| `elements`             | integer \| string | Optional                 | Number of columns per row for Gallery fields                                                    |
| `render`               | string            | Optional                 | Field-type-specific render mode override                                                        |

Exactly one of `post_id`, `term_id`, `user_id`, `option_page`, or `wc_product_attribute` must be provided to identify the location.

{% hint style="warning" %}
`comment_id` is accepted without a validation error, but is currently **not** wired to any location resolution in this function — passing only `comment_id` returns `null`.
{% endhint %}

### Return

| Type     | Description                                                                                         |
| -------- | --------------------------------------------------------------------------------------------------- |
| `string` | The rendered field output                                                                           |
| `null`   | If no location key (`post_id`/`term_id`/`user_id`/`option_page`/`wc_product_attribute`) is provided |
