> For the complete documentation index, see [llms.txt](https://wplake.gitbook.io/advanced-views/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wplake.gitbook.io/advanced-views/layouts/component-options/wordpress-hooks.md).

# Layout WordPress hooks

Advanced Views includes a set of WordPress hooks, allowing you to customize the [*Layouts*](/advanced-views/getting-started/first-layout.md) from your theme (or code snippets). Pay attention that in ordinary cases, customization should be done using the [Layout Controller](/advanced-views/layouts/code-fields/layout-controller.md).

{% hint style="info" %}
This page focuses only on the *Layout* hooks; check [this page](/advanced-views/features/wordpress-hooks.md) to see generic plugin hooks.
{% endhint %}

## 1. Layout hooks list

{% hint style="info" %}
Please make sure you've installed the latest version of the plugin before using these filters.

If you need to customize something, but a filter or hook is unavailable, then [contact us](https://advanced-views.com/support/), and we will try to add it as soon as possible.
{% endhint %}

[advanced\_views/layout/field\_data](#field-data)

[advanced\_views/layout/field\_data/type={fieldType}](#field-data)

[advanced\_views/layout/field\_data/name={fieldName}](#field-data)

[advanced\_views/layout/field\_data/layout\_id={id}](#field-data)

[advanced\_views/layout/custom\_variables](#custom-view-variables-pro)

[advanced\_views/custom\_variables/layout\_id={id}](#custom-layout-variables)

[do\_shortcode\_tag](#shortcode-output)

## 2. Layout hook descriptions

#### Field Data

Allows you to amend field data before it's inserted into the template.

{% code overflow="wrap" %}

```php
add_filter('advanced_views/layout/field_data', function ($fieldData, $fieldMeta, $viewId) {
    // any modifications to the $fieldData here
    return $fieldData;
}, 10, 3);
```

{% endcode %}

* `$field_data` (array) Field data
* `$field_meta` (Field\_Meta\_Interface) Information about the field.
* `$view_id` (string) Unique ID of the current *Layout*.

#### Custom Layout Variables

Allows to add custom variables to the custom markup.&#x20;

{% code overflow="wrap" %}

```php
add_filter('advanced_views/layout/custom_variables', function ($phpVariables, $viewId, $objectId, $fieldValues) {
    // any modifications to the $phpVariables here
    return $phpVariables;
}, 10, 4);
```

{% endcode %}

* `$php_variables` (array) Current custom variables (Custom Markup Variables field, an associative array of values, where keys are variable names). These variables can be accessed in the custom markup with brackets, like `{VARIABLE_NAME}`
* `$view_id` (string) Unique ID of the current *Layout*
* `$object_id` (int) ID of the current data post
* `$field_values` (array) An associative field values array, where keys are field identifiers

#### Shortcode output

It’s a built-in WordPress hook that allows modifying the output of the whole shortcode. Code example shown below. Read more [here](https://developer.wordpress.org/reference/hooks/do_shortcode_tag/).

```php
add_filter('do_shortcode_tag', function ($output, $tag, $attr) {
    if ('acf_views' != $tag) {
        return $output;
    }

    // todo my custom changes for $output

    return $output;
}, 10, 3);
```
